User:Elliot/ajaxpatrol.js
The UESPWiki – Your source for The Elder Scrolls since 1995
Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
function ajaxPatrolLinks() {
var a = document.evaluate('//span[@class="patrollink"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; // dif article
var b = document.evaluate('//div[@class="patrollink"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; // new article
if (b) a = b;
if (a) {
var div = a.parentNode;
var url = a.href;
a.onclick = function (event) {
var aj = sajax_init_object();
if (aj) {
while (div.firstChild) { div.removeChild(div.firstChild) };
div.appendChild(document.createTextNode('[Marking as patrolled...]'));
aj.onreadystatechange = function () {
if (aj.readyState == 4 && aj.status == 200) {
while (div.firstChild) { div.removeChild(div.firstChild) };
div.style.cssText = 'color:Silver';
div.appendChild(document.createTextNode('[Marked as patrolled]'));
aj.onreadystatechange = null;
}
}
aj.open("GET", url, true);
aj.send(null);
return false;
}
}
}
}
addOnloadHook(ajaxPatrolLinks);
addOnloadHook(ajaxPatrolLinks);