User:Mr.Z-man/patrollinks.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
var showbydefault; var plinksindex = 0; function patrollinks () { if (wgPageName == "Special:NewPages" ) { addPortletLink('p-cactions', 'javascript:patrollinksclick()', "patrol links", "ca-plinks-show1", "Add patrol links to this page"); if (!document.getElementById('p-cactions') || showbydefault) { addOnloadHook(patrollinksclick); } if (showbydefault) { document.getElementById('ca-plinks-show1').style.display = 'none'; } } } addOnloadHook(patrollinks); function patrollinksclick () { if (document.getElementById('p-cactions')) { addPortletLink('p-cactions', 'javascript:patrollinkshide()', "hide patrol links", "ca-plinks-hide", "Hide patrol links"); document.getElementById('ca-plinks-show1').style.display = 'none'; } unpatrolled = getElementsByClassName(document, "li", "not-patrolled"); while(plinksindex < unpatrolled.length) { code = unpatrolled[plinksindex].getElementsByTagName('a')[0].href.toString() rcid = code.substring(code.indexOf('rcid=')+5); title = code.substring(code.indexOf('title=')+6, code.indexOf('&rcid=')); link = wgScript +'?title=' + title + '&action=markpatrolled&rcid=' + rcid; plink = document.createElement("a"); stuff = document.createTextNode("Patrol"); plink.appendChild(stuff); plink.href = link; openb = document.createTextNode(" ["); closeb = document.createTextNode("]"); bracket = document.createElement("span"); bracket.id = "plink" + plinksindex ; bracket.appendChild(openb); bracket.appendChild(plink); bracket.appendChild(closeb); unpatrolled[plinksindex].appendChild(bracket); plinksindex++ } } function patrollinkshide() { var j for (j = 0; j<plinksindex ; j++) { document.getElementById('plink'+j).style.display = 'none'; } document.getElementById('ca-plinks-hide').style.display = 'none'; addPortletLink('p-cactions', 'javascript:patrollinksshowagain()', "patrol links", "ca-plinks-show", "Add patrol links to unpatrolled entries"); } function patrollinksshowagain() { var j for (j = 0; j<plinksindex ; j++) { document.getElementById('plink'+j).style.display = ''; } document.getElementById('ca-plinks-show').style.display = 'none'; addPortletLink('p-cactions', 'javascript:patrollinkshide()', "hide patrol links", "ca-plinks-hide", "Hide patrol links"); }

