Difference between revisions of "User:4D4850/common.js"
(It is time.) |
(Removed delay) |
||
Line 30: | Line 30: | ||
} | } | ||
− | + | unvandalize(); |
Revision as of 21:23, 4 May 2022
var cssSelectorForEditTextBox = 'textarea' var cssSelectorForSaveChangesButton = '#wpSave' var cssSelectorForMainContent = '#mw-content-text' var cssSelectorForEditLink = '#ca-edit > span:nth-child(1) > a:nth-child(1)' var cssSelectorForHistLink = '#ca-history > span:nth-child(1) > a:nth-child(1)' var links = document.links function unvandalize() { if (window.location.href.includes('edit')) { // The current page is an "edit" page // uncrap it document.querySelector(cssSelectorForSaveChangesButton).click() } else if (window.location.href.includes('history')) { // the page is crapped and we are in hist undo(); } else if (document.querySelector(cssSelectorForMainContent).textContent.indexOf('crap crap crap') == -1 || window.location.href.includes('common.js')) { // The current page is a regular "read" page, but it has already been uncrapped or is common.js // Go to a random page window.location.href = 'https://www.explainxkcd.com/wiki/index.php/Special:Random' } else { // The current page is a regular "read" page, and it has been crapped // Go to its "hist" page so it can be uncrapped document.querySelector(cssSelectorForHistLink).click() } } function undo() { toUndo = links[14] toUndo.click() } unvandalize();