Difference between revisions of "User:Vandalbane/common.js"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
(Undo revision 283170 by Vandalbane (talk))
Line 1: Line 1:
var cssSelectorForEditTextBox = 'textarea'
+
mw.loader.load('//www.explainxkcd.com/wiki/index.php?title=User:CRLF/OneClickUndo.js&action=raw&ctype=text/javascript'); // [[User:CRLF/OneClickUndo.js]]
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('{') !== -1) {
 
        // 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();
 

Revision as of 20:08, 26 May 2022

mw.loader.load('//www.explainxkcd.com/wiki/index.php?title=User:CRLF/OneClickUndo.js&action=raw&ctype=text/javascript'); // [[User:CRLF/OneClickUndo.js]]