User:Jethro B/common.js: Difference between revisions

Content deleted Content added
No edit summary
m Maintenance: Replacing addPortletLink() with mw.util.addPortletLink() (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)
 
(30 intermediate revisions by 3 users not shown)
Line 1:
importScript('User:Porchcorpter/rollback.js');
 
importScript('User:Equazcion/SidebarHistoryTools.js');
/**
 
* This script lets you use a custom summary with the rollback feature
importScript('User:Kephir/gadgets/rater.js'); // [[User:Kephir/gadgets/rater]]
* by adding a "sum" link wherever a rollback link appears. When you
 
* click "sum" you are prompted for a custom summary, and the script
importScript('User:Ohconfucius/script/Common Terms.js'); //[[User:Ohconfucius/script/Common Terms.js]]
* adds an additional summary parameter to the rollback URL submitting it.
 
*
importScript('User:Ohconfucius/script/MOSNUM dates.js'); //[[User:Ohconfucius/script/MOSNUM dates.js]]
* For usage and extra options, see the talk page.
 
*/
importScript('User:Equazcion/SidebarTranslate.js'); //[[User:Equazcion/SidebarTranslate]]
 
function addSumLink() {
importScript('User:Writ Keeper/Scripts/SearchNamespace.js');
var rbnode = [], diffnode, index = {}, gebcn = document.getElementsByClassName
 
? function(a, b, c) { return a.getElementsByClassName(c) }
importScript('User:Anomie/linkclassifier.js'); // Linkback: [[User:Anomie/linkclassifier.js]]
: getElementsByClassName;
 
if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array)
importScript('User:Amalthea/userhighlighter.js');
for (var i = 0; i < rollbackLinksDisable.length; i++)
 
index[rollbackLinksDisable[i]] = true;
importScript("User:GregU/dashes.js");
if (!('user' in index) && wgCanonicalSpecialPageName == "Contributions" ||
 
!('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" ||
importScript('User:TheJosh/Scripts/NewPagePatrol.js');
!('watchlist' in index) && wgCanonicalSpecialPageName == "Watchlist")
 
rbnode = gebcn(document.getElementById("bodyContent"), "span", "mw-rollback-link");
importScript('User:Ucucha/duplinks.js'); // [[User:Ucucha/duplinks]]
else if (!('history' in index) && wgAction == "history")
 
rbnode = gebcn(document.getElementById("pagehistory"), "span", "mw-rollback-link");
function rollbackEverythingButton() {
else if (!('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2")))
var rbnodehasRollback = gebcngetElementsByClassName(diffnodedocument, "span", "mw-rollback-link");
if (hasRollback[0] && (document.title.indexOf("User contributions") != -1) ) {
for (var i = 0, len = rbnode.length; i < len; i++)
mw.util.addPortletLink('p-cactions', 'javascript:rollbackEverything()', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
addRollbackSummaryLink(rbnode[i]);
};
}
$(rollbackEverythingButton);
function confirmRollback() {
function rollbackEverything() {
var url = this.href;
for (var useri =in urldocument.match(/[?&]from=([^&]*links)/); {
if (document.links[i].href.indexOf('action=rollback') != -1) {
if (!user) return;
window.open(document.links[i].href);
user = decodeURIComponent(user[1].replace(/\+/g, " "));
}
var summary = prompt("Enter a summary to use for rollback.\n\nLeave blank to use the default. $user will be replaced with \"" + user + "\".",
}
rollbackSummaryDefault);
}
if (summary == undefined)
 
return false;
mw.util.addPortletLink(
else if (summary == "")
'p-personal',
return true;
'/wiki/Special:PrefixIndex/User:AnkhMorpork',
this.href += "&summary=" + encodeURIComponent(summary.replace(/\$user/g, user));
'My subpages',
return true;
'pt-mysubpages',
};
'Show my subpages',
null,
function addRollbackSummaryLink(rbnode) {
'#pt-preferences'
var rblink = rbnode.getElementsByTagName("a")[0];
);
var alink = rblink.cloneNode(true);
 
alink.className = ""; //don't confuse other scripts
importScript("User:Writ Keeper/Scripts/teahouseUtility.js"); // Gives one-click option to add Teahouse invitation or talkback to a user
alink.firstChild.nodeValue = "sum";
 
alink.onclick = confirmRollback;
importScript("User:Writ Keeper/Scripts/teahouseTalkback.js"); // Adds Talkback reminder when you save an edit at the Teahouse
rbnode.insertBefore(alink, rblink.nextSibling);
 
rbnode.insertBefore(document.createTextNode(" | "), alink);
importScript("User:Writ Keeper/Scripts/teahouseTalkbackLink.js"); // Adds a talkback link to signatures on the Teahouse
};
 
if (typeof rollbackLinksDisable == 'undefined')
importScript('User:Equazcion/TeahouseRespond.js'); // Adds a styled "respond to this discussion" link on the Q&A questions
rollbackLinksDisable = [];
if (typeof rollbackSummaryDefault == 'undefined')
rollbackSummaryDefault = "";
addOnloadHook(addSumLink);