User:Microchip08/talkpageplus.js

From Simple English Wikipedia, the free encyclopedia

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Talk_page_section_tabs
function talkpageplus()
{
    var talkpagelink = document.getElementById('ca-talk'); // look for the discussion tab
    if(!talkpagelink) return;
    if (talkpagelink.className == 'new') // is it a redlink?
    {
        talkpagelink.firstChild.href += '&section=new'; // add &section=new to the end of the link
    var tab = document.getElementById('ca-talk'); //go find it again
    if(!tab) return;
    var tablink = tab.getElementsByTagName('a')[0];
    if(!tablink) return;
    tablink.firstChild.nodeValue = '+'; // now change it to a + instead of the normal "discussion"
    tablink.style.paddingLeft = ".4em";
    tablink.style.paddingRight = ".4em";
    } // not a redlink? jump to here
} //end

addOnloadHook(talkpageplus); // execute function above