User:Thunderkatz/vector.js

function botrollback { var rollbacklinks = getElementsByClassName(document.getElementById('bodyContent'),"*","mw-rollback-link"); var botrblinks = new Array; for (var j = 0; j< rollbacklinks.length; j++) { var rbbs = document.createElement('span'); var rba = rollbacklinks[j].getElementsByTagName('a')[0]; var rbba = document.createElement('a'); rbba.innerHTML = "as bot"; rbba.href = rba.href + '&bot=1'; if ( rollbacklinks[j].innerHTML[0] == "[" ) { rbbs.appendChild(document.createTextNode("[")); var blue_hack = document.createElement('a'); blue_hack.innerHTML = "rollback"; blue_hack.className = "mw-rollback-link"; blue_hack.href = rba.href; rbbs.appendChild(blue_hack); rbbs.appendChild(document.createTextNode(" | ")); }     rbbs.appendChild(rbba); if ( rollbacklinks[j].innerHTML[rollbacklinks[j].innerHTML.length-1] == "]" ) rbbs.appendChild(document.createTextNode("]")); if (rollbacklinks[j].nextSibling == undefined) { rollbacklinks[j].parentNode.appendChild(document.createTextNode(" ")); rollbacklinks[j].parentNode.appendChild(rbbs); rollbacklinks[j].parentNode.removeChild(rollbacklinks[j]); } else { rollbacklinks[j].parentNode.insertBefore(rbbs,rollbacklinks[j].nextSibling); rollbacklinks[j].parentNode.insertBefore(document.createTextNode(rbbs.nextSibling.textContent),rbbs); }     botrblinks.push(rbbs); } for (var j = 0; j< botrblinks.length; j++) { botrblinks[j].className = "mw-rollback-link"; } } addOnloadHook(botrollback);