User:JJPMaster/Scripts/SuppressRedirect.js: Difference between revisions

Content deleted Content added
No edit summary
exclude nonexistent and special pages
Line 4:
}
$(() => {
if (mw.config.get("wgArticleId") !== 0) {
var porty = mw.util.addPortletLink('p-cactions', '#', 'Suppress redirect', 'pt-supp', 'Move and suppress the redirect');
ad = "(using [[User:JJPMaster/SuppressRedirect|SuppressRedirect]])";
$("#bodyContent").append(`
<div id="suppressRedirectDialog">
Why do you want to suppress this redirect?
<select name="criterion" id="PMRcriterion">
<option>Select theselect name="criterion</option" id="PMRcriterion">
<option>Select the criterion</option>
<option>Reverting page move vandalism ([[WP:PMRC#1]])</option>
<option>Moving pages within a requester's own userspace to another ___location if a desire for deletion is expressed ([[WP:PMRC#2]])</option>
<option>Moving pages from a title unambiguously created in error or in the incorrect namespace ([[WP:PMRC#3]])</option>
<option>Round-robin page move ([[WP:PMRC#4]]</option>
<option>File shadows Wikimedia Commons file ([[WP:PMRC#5]])</option>
<option>Moving from mainspace to other namespace ([[WP:PMRC#6]])</option>
<option>Moving recently created page from implausible title ([[WP:PMRC#7]])</option>
<option>Moving editnotice to subpage of [[Template:Editnotices]] ([[WP:PMRC#8]])</option>
<option>Redirect would meet a criterion for speedy deletion ([[WP:PMRC#9]])</option>
</select><br />
<input type="text" id="toMoveTitle" name="toMoveTitle" /><label for="toMoveTitle">The title the page will be moved to</label><br />
<input type="checkbox" id="moveSubpages" name="moveSubpages" checked /><label for="moveSubpages">Move subpages</label><br />
<input type="checkbox" id="moveTalk" name="moveTalk" checked /><label for="moveTalk">Move talk page</label><br />
<button type="button" id="moveForReal">Move page and suppress redirect</button>
</div>
`);
$("#suppressRedirectDialog").hide();
$(porty).click(() => $("#suppressRedirectDialog").dialog());
$("#moveForReal").click(function() {
var critValue = document.getElementById("PMRcriterion").value;
var criterion;
if(critValue !== "Redirect would meet a criterion for speedy deletion ([[WP:PMRC#9]])")
criterion = critValue;
else {
var innerCrit = prompt("What criterion?");
if(innerCrit)
criterion = `Redirect would meet criterion [[WP:CSD#${innerCrit}|${innerCrit}]] for speedy deletion ([[WP:PMRC#9]])`;
else criterion = critValue;
}
var params = {
action: 'move',
from: mw.config.get("wgPageName"),
to: document.getElementById("toMoveTitle").value,
reason: criterion + " " + ad,
movetalk: checkToBoolean(document.getElementById("moveTalk").value),
movesubpages: checkToBoolean(document.getElementById("moveSubpages").value),
noredirect: true,
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
window.___location.href = mw.config.get("wgArticlePath").replace("$1", "") + document.getElementById("toMoveTitle").value;
} );
});
}
});