User:Dusti/common.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin can be added at User:Dusti/common.css. |
//<nowiki>
if(wgCanonicalNamespace == "Project" || wgCanonicalNamespace == "Project_talk")
{
function autoClose(e)
{
if (!e) var e = window.event;
var regexResults = /title=([^&]+).+section=([^&]+)/.exec($(e.target).siblings().attr("href"));
var pageTitle = regexResults[1];
var sectionIndex = regexResults[2];
var sectionTitle = $(e.target).siblings().attr("title").substr(14);
var rationale = prompt("Please enter your rationale.");
if(rationale == null || rationale.length <= 0)
{
alert("You didn't enter a rationale.");
return false;
}
var requestData = {
format : 'json',
action : 'raw',
title : pageTitle,
section : sectionIndex,
};
$.post("/w/index.php", requestData, function(responseText)
{
var sectionRegex = /(==+)([^=]+)\1/.exec(responseText);
var sectionTitle = sectionRegex[2];
var newContent = sectionRegex[0]+ "\n{{subst:archive top|"+rationale+" ~~~~}}\n" + responseText.substr(sectionRegex[0].length) + "\n{{subst:archive bottom}}";
var replyData = {
format : 'json',
action : 'edit',
notminor : true,
title : pageTitle,
text : newContent,
section : sectionIndex,
summary : "Closing section: " + sectionTitle,
token : mw.user.tokens.get('csrfToken')
};
$.post("/w/api.php", replyData)
.done(function(){alert("Section closed.");document.location.reload(true);})
.fail(function(){alert("Section close failed.");});
})
return false;
}
function autoCloserSetup()
{
var sectionHeaders= $("#mw-content-text h2,#mw-content-text h3,#mw-content-text h4,#mw-content-text h5,#mw-content-text h6");
var offset = 1;
sectionHeaders.each(function(index, element)
{
var editSectionLink= $(element).children(".editsection")
if(editSectionLink.length > 0)
{
editSectionLink = editSectionLink[0];
var autoCloser = document.createElement("a");
autoCloser.href = "#";
$(autoCloser).attr("sectionIndex", index + offset);
autoCloser.innerHTML = "Close section";
var editSectionContents = $(editSectionLink).html();
editSectionLink.innerHTML = "[";
editSectionLink.appendChild(autoCloser);
editSectionLink.innerHTML = editSectionLink.innerHTML + "] " + editSectionContents;
autoCloser.onclick = autoClose;
}
else
{
offset = offset - 1;
}
});
$("#bodyContent [sectionIndex]").click(autoClose);
}
$(document).ready(autoCloserSetup());
}
//</nowiki>
importScript('User:Porchcorpter/rollbackSum.js');
//Mass rollback function
//Written by John254
//Adapted from User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
function rollbackEverythingButton() {
var hasRollback = getElementsByClassName(document, "span", "mw-rollback-link");
if (hasRollback[0] && (document.title.indexOf("User contributions") != -1) ) {
mw.util.addPortletLink('p-cactions', 'javascript:rollbackEverything()', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
}
}
$(rollbackEverythingButton);
function rollbackEverything() {
for (var i in document.links) {
if (document.links[i].href.indexOf('action=rollback') != -1) {
window.open(document.links[i].href);
}
}
}
/* User:Technical_13/Scripts/OneClickArchiver.js */
importScript( 'User:Technical_13/Scripts/OneClickArchiver.js' );// Backlink: [[User:Technical_13/Scripts/OneClickArchiver.js]]
importScript('User:Enterprisey/delsort.js'); // Backlink: [[User:Enterprisey/delsort.js]]
importScript('User:Enterprisey/reply-link.js'); // Backlink: [[User:Enterprisey/reply-link.js]]
importScript('User:DannyS712/PageMoverClosure.js'); // Backlink: [[User:DannyS712/PageMoverClosure.js]]
importScript('User:Zackmann08/unwatch_deleted.js'); // Backlink: [[User:Zackmann08/unwatch_deleted.js]]
importScript('User:TheJosh/Scripts/NewPagePatrol.js'); // Backlink: [[User:TheJosh/Scripts/NewPagePatrol.js]]
importScript('User:MusikAnimal/responseHelper.js'); // Backlink: [[User:MusikAnimal/responseHelper.js]]
importScript('User:Lourdes/SpecialNewPages.js'); // Linkback: [[User:Lourdes/SpecialNewPages.js]]
importScript('User:Pythoncoder/voteSymbols.js'); // Backlink: [[User:Pythoncoder/voteSymbols.js]]
importScript('User:RedWarn/.js'); // Backlink: [[User:RedWarn/.js]]