User:JJPMaster/easysymunblock.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes.
- Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
- Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
- Opera, Konqueror and Safari users can just click the Reload button.
- Chrome: press Ctrl+F5 or Shift+F5
if(mw.config.get("wgNamespaceNumber") == 2 && !(mw.config.get("wgPageName").includes("/"))) {
mw.util.addPortletLink("p-cactions", "#", "Symbolically unblock", "p-symunblock", "Symbolically unblock");
}
$("#p-symunblock").click(function() {
var reason = prompt("Why are you unblocking this person?", "None specified");
var params = {
action: 'parse',
page: mw.config.get("wgPageName") + "/common.js",
format: 'json'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
var pageContent = data.parse.text['*'];
console.log(pageContent);
if(pageContent.includes(`<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="s2">"sb_2b1d632e49dbff953d903cbb5af6dbeea12fe8d1"</span><span class="p">,</span> <span class="s2">"6583c0693b0c2ede5a90e65c8ed2da8bb96eec65"</span><span class="p">);</span>`)) {
var params = {
action: 'edit',
title: mw.config.get("wgPageName") + "/common.js",
text: `// Your symbolic block has been reversed. You may now remove the code below and restore the previous revision.
localStorage.removeItem("sb_2b1d632e49dbff953d903cbb5af6dbeea12fe8d1");
localStorage.removeItem("sb_c409561930c527cf6cfceff3369f09ca4a47f0d3");
`,
summary: 'Reversing symbolic block: ' + reason + " (automated)",
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
params = {
action: 'protect',
title: mw.config.get("wgPageName") + "/common.js",
protections: 'edit=all|move=all',
expiry: 'infinite',
reason: 'Reversing symbolic block: ' + reason + ' (automated)',
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
} );
params = {
action: 'edit',
title: "Uncyclopedia:Symbolic block/Log",
appendtext: `\r\n*'''UNBLOCKED''': {{user|` + mw.config.get("wgTitle") + `}} - Reason: ` + reason + `: Unblocked on ` + new Date().toString(),
summary: "-[[User:" + mw.config.get("wgTitle") + "|" + mw.config.get("wgTitle") + "]] (automated)",
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
}
else {
alert("The user is not currently blocked, so, sorry!");
}
});
});