User:HakanIST/global.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// [[File:Hoo man/tagger.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/tagger.js&action=raw&ctype=text/javascript');
if(typeof(taggerConfig) == 'undefined') taggerConfig = {};
taggerConfig.noDeleteOnly = false;
//<nowiki>
if(typeof(taggerConfig) == 'undefined') taggerConfig = {};
taggerConfig.tags = [];
taggerConfig.editSummary = [];
taggerConfig.tags[1] = '{{delete|test/off-topic}}';
taggerConfig.editSummary[taggerConfig.tags[1]] = '+ delete, test - off-topic';
taggerConfig.tags[2] = '{{delete|Cross-wiki vandalism}}';
taggerConfig.editSummary[taggerConfig.tags[2]] = '+ delete, cross-wiki vandalism';
taggerConfig.tags[3] = '{{delete|Blanked by the author}}';
taggerConfig.editSummary[taggerConfig.tags[3]] = '+ delete, blanked by the author';
taggerConfig.tags[4] = '{{delete|Spam/Cross-wiki spam}}';
taggerConfig.editSummary[taggerConfig.tags[4]] = '+ delete, spam';
taggerConfig.tags[5] = '{{speedy|test, off-topic}}';
taggerConfig.editSummary[taggerConfig.tags[5]] = '+ delete, test, off-topic';
taggerConfig.tags[6] = '{{speedy|off-topic, spam}}';
taggerConfig.editSummary[taggerConfig.tags[6]] = '+ delete, off-topic, spam';
taggerConfig.tags[7] = '{{delete|No useful information/vandalism}}';
taggerConfig.editSummary[taggerConfig.tags[7]] = '+ delete';
taggerConfig.tags.other = 'This is used for the option you have to select to be able to insert a custom template';
//</nowiki>
// [[File:Hoo man/useful_links.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/useful_links.js&action=raw&ctype=text/javascript');
/*
* Will pop-up a confirmation dialog when rollback link is clicked from Watchlist.
* Hit the "cancel" button if you had clicked Rollback accidentally and the edit will not be reverted.
* To install add importScript('User:Zvn/confirmwatchlistrollback.js'); to your monobook.js.
*/
function confirmWatchlistRollback()
{
if(mw.config.get('wgCanonicalSpecialPageName')==='Watchlist' || mw.config.get('wgCanonicalSpecialPageName')==='Recentchanges')
{
var rollbackNodes;
if(!document.getElementsByClassName)
{
rollbackNodes=getElementsByClassName(document.getElementById("bodyContent"),"span","mw-rollback-link");
}
else
{
rollbackNodes=document.getElementsByClassName('mw-rollback-link');
}
var rollbackclicked=function (e)
{
if(!e)
{
e=window.event;
}
if(!confirm("Are you sure you want to rollback this edit?"))
{
if(e.stopPropagation)
{
e.stopPropagation();
e.preventDefault();
}
else
{
e.cancelBubble=true;
e.returnValue=false;
}
}
};
for (var i=0;i<rollbackNodes.length;i++)
{
try { rollbackNodes[i].childNodes[1].onclick=rollbackclicked; } catch( e) { /* node is null */ }
}
}
}
$(confirmWatchlistRollback);
/* Global JavaScript
Function importAnyScript() by Mike.lifeguard
*/
function importAnyScript(lang,family,script) {
//use importScriptURI with the full-qualified source, else importScript(); runs in the context of the remote wiki, finding nothing.
mw.loader.load('https://'
+ encodeURIComponent(lang) + '.'
+ encodeURIComponent(family) + '.org/w/index.php?title='
+ encodeURIComponent(script) + '&action=raw&ctype=text/javascript');
}
importAnyScript('meta','wikimedia','User:Quentinv57/HideButtonsFromNonGsProjects.js');
// Provides several useful functions for rollback (custom edit summary, mark as bot edits and mass revert)
// by [[m:user:Hoo man]] <http://meta.wikimedia.org/wiki/User:Hoo_man/Scripts/Smart_rollback>
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/smart_rollback.js&action=raw&ctype=text/javascript');
// Shows the number of active sysops
// by [[m:user:Hoo man]] <http://meta.wikimedia.org/wiki/User:Hoo_man/active_sysops.js>
// [[File:Hoo man/active_sysops.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/active_sysops.js&action=raw&ctype=text/javascript');
/************* StewardLinks *** by [[m:User:Erwin]] **********/
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Erwin/stewardlinks.js&action=raw&ctype=text/javascript');
//Preloads common deletion reasons for crosswiki use
// [[File:Snowolf_GS_delete.js]]
//mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Snowolf/GS_delete.js&action=raw&ctype=text/javascript');
//Preloads common deletion reasons for crosswiki use
// [[File:Snowolf_GS_delete.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Rxy/GS_delete.js&action=raw&ctype=text/javascript');
/**
* StewardScript extends the user interface for Wikimedia stewards' convenience.
* @see https://meta.wikimedia.org/wiki/StewardScript
*/
$.getScript('//tools.wmflabs.org/meta/scripts/pathoschild.stewardscript.js');
// Mass revdel
$.when( mw.loader.using( 'mediawiki.api' ), $.ready ).then( function()
{
var api = new mw.Api();
if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions")
{
$("ul.mw-contributions-list").before("<div style='display:inline-block;' id='revdelCP'>Revision deletion: <input type='button' id='revdelSelectAll' value='Select all'><input type='button' id='revdelSelectNone' value='Select none'>\
<span style='white-space:nowrap;'><input type='checkbox' id='revdelContent' name='revdelOptions' value='content'> delete content</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='revdelName' name='revdelOptions' value='userName'> delete user name</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='revdelComment' name='revdelOptions' value='editSummary'> delete edit summary</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='undelContent' name='revdelOptions' value='content'> undelete content</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='undelName' name='revdelOptions' value='userName'> undelete user name</span> \
<span style='white-space:nowrap;'><input type='checkbox' id='undelComment' name='revdelOptions' value='editSummary'> undelete edit summary</span> \
<br/><select id='wpRevDeleteReasonList'><option value='other'>Other reason</option></select><input name='wpReason' size='60' id='wpReason' maxlength='100'>\
<input type='button' class='revdelSubmit' id='revdelSubmit' value='Revdel selected entries'> <input type='button' class='revdelSubmit' id='oversightSubmit' value='Oversight selected entries'></div>");
$("ul.mw-contributions-list .mw-revdelundel-link").each(function(ind,el){
var revId = /ids=(\d+)/.exec($(this).children("a").attr("href"))[1];
var pageTitle = /target=([^&]+)/.exec($(this).children("a").attr("href"))[1];
el.innerHTML = "<input type='checkbox' name='"+decodeURIComponent(pageTitle)+"' class='revdelIds' value='"+revId+"'>";
});
$("ul.mw-contributions-list").after("</form>");
//load canned summaries
$.get("/w/index.php?title=MediaWiki:Revdelete-reason-dropdown&action=raw",function(data)
{
reasons = data.replace(/\*\* ([^\*]+)/g, '<option value="$1">$1</option>');
reasons = reasons.replace(/\* ([^<]+)([^\*]+)/g, '<optgroup label="$1">$2</optgroup>');
$('#wpRevDeleteReasonList').append(reasons);
});
//attach handlers
$("#revdelSelectAll").click(
function()
{
$('input.revdelIds').each(function()
{
$(this).prop("checked", true);
})
}
);
$("#revdelSelectNone").click(
function()
{
$('input.revdelIds').each(function()
{
$(this).prop("checked", false);
})
}
);
$("#revdelSubmit").click(
function()
{
//figure out which revisions and pages we're working on.
var revCount = 0;
var numTitles = 0;
var pageTitles = {};
$("input.revdelIds:checked").each(function(ind)
{
revCount = ind + 1;
if(ind > 49)
{
alert("You can't do more than 50 revdels at once! Canceling...");
return false;
}
if(typeof pageTitles[$(this).attr("name")] == "undefined")
{
pageTitles[$(this).attr("name")] = $(this).val();
numTitles++;
}
else
{
pageTitles[$(this).attr("name")] = pageTitles[$(this).attr("name")] + "|" + $(this).val();
}
});
if(numTitles == 0)
{
alert("You didn't select any revisions to delete!");
return false;
}
var confirmString = "You are attempting to modify " + revCount + " revisions.\n\nThe following revision attributes will be changed:\n";
//figure out what we're doing to each revision. This is pretty clunky, but whatever.
var deleteString = "";
var revealString = "";
var typeString = "revdel";
if($("#revdelContent").prop("checked") == $("#undelContent").prop("checked"))
{
confirmString = confirmString + "-Content visibility won't change.\n";
}
else if($("#revdelContent").prop("checked"))
{
deleteString = "content";
confirmString = confirmString + "-Content will be deleted.\n";
}
else
{
revealString = "content";
confirmString = confirmString + "-Content will be revealed.\n";
}
if($("#revdelComment").prop("checked") == $("#undelComment").prop("checked"))
{
confirmString = confirmString + "-Edit summary visibility won't change.\n";
}
else if($("#revdelComment").prop("checked"))
{
if(deleteString != "")
{
deleteString = deleteString + "|";
}
deleteString = deleteString + "comment";
confirmString = confirmString + "-Edit summary will be deleted.\n";
}
else
{
if(revealString != "")
{
revealString = revealString + "|";
}
revealString = revealString + "comment";
confirmString = confirmString + "-Edit summary will be revealed.\n";
}
if($("#revdelName").prop("checked") == $("#undelName").prop("checked"))
{
confirmString = confirmString + "-User name visibility won't change.\n";
}
else if($("#revdelName").prop("checked"))
{
if(deleteString != "")
{
deleteString = deleteString + "|";
}
deleteString = deleteString + "user";
confirmString = confirmString + "-User name will be deleted.\n";
}
else
{
if(revealString != "")
{
revealString = revealString + "|";
}
revealString = revealString + "user";
confirmString = confirmString + "-User name will be revealed.\n";
}
if(deleteString == "" && revealString == "")
{
alert("You didn't select any properties of the revisions to change!");
return false;
}
var summary = "";
//construct the revdel summary
if($("#wpRevDeleteReasonList").val() == "other")
{
if($("#wpReason").val() == "")
{
alert("You didn't select or write in an edit summary for the logs!");
return false;
}
summary = $("#wpReason").val();
}
else
{
summary = $("#wpRevDeleteReasonList").val();
if($("#wpReason").val() != "")
{
summary = summary + ": " + $("#wpReason").val();
}
}
confirmString = confirmString + "\nYour revdel summary is: "+ summary +"\n\nAre you sure you want to do this?";
if(confirm(confirmString))
{
var numCompleted = 0;
for (title in pageTitles)
{
var ajaxData;
ajaxData = {action:"revisiondelete",type:"revision",ids:pageTitles[title],reason:summary};
if(deleteString != "")
{
ajaxData.hide=deleteString;
}
if(revealString != "")
{
ajaxData.show=revealString;
}
api.postWithToken('csrf', ajaxData).done(function()
{
numCompleted++;
if(numCompleted == numTitles)
{
alert("modified " + revCount + " revision(s) successfully!");
return false;
}
});
}
}
return false;
}
)
$("#oversightSubmit").click(
function()
{
//figure out which revisions and pages we're working on.
var revCount = 0;
var numTitles = 0;
var pageTitles = {};
$("input.revdelIds:checked").each(function(ind)
{
revCount = ind + 1;
if(ind > 49)
{
alert("You can't do more than 50 revdels at once! Canceling...");
return false;
}
if(typeof pageTitles[$(this).attr("name")] == "undefined")
{
pageTitles[$(this).attr("name")] = $(this).val();
numTitles++;
}
else
{
pageTitles[$(this).attr("name")] = pageTitles[$(this).attr("name")] + "|" + $(this).val();
}
});
if(numTitles == 0)
{
alert("You didn't select any revisions to delete!");
return false;
}
var confirmString = "You are attempting to modify " + revCount + " revisions.\n\nThe following revision attributes will be changed:\n";
//figure out what we're doing to each revision. This is pretty clunky, but whatever.
var deleteString = "";
var oversighting = -1;
if($("#revdelContent").prop("checked") == $("#undelContent").prop("checked"))
{
confirmString = confirmString + "-Content visibility won't change.\n";
}
else if($("#revdelContent").prop("checked"))
{
deleteString = "content";
confirmString = confirmString + "-Content will be oversighted.\n";
oversighting = 1;
}
else
{
if(oversighting == 1)
{
alert("we can't oversight and un-oversight edits at the same time!");
return false;
}
deleteString = "content";
confirmString = confirmString + "-Content will be returned to normal (admin-only) revision deletion.\n";
oversighting = 0;
}
if($("#revdelComment").prop("checked") == $("#undelComment").prop("checked"))
{
confirmString = confirmString + "-Edit summary visibility won't change.\n";
}
else if($("#revdelComment").prop("checked"))
{
if(oversighting == 0)
{
alert("we can't oversight and un-oversight edits at the same time!");
return false;
}
if(deleteString != "")
{
deleteString = deleteString + "|";
}
deleteString = deleteString + "comment";
confirmString = confirmString + "-Edit summary will be oversighted.\n";
oversighting = 1;
}
else
{
if(oversighting == 1)
{
alert("we can't oversight and un-oversight edits at the same time!");
return false;
}
if(deleteString != "")
{
deleteString = deleteString + "|";
}
deleteString = deleteString + "comment";
confirmString = confirmString + "-Edit summary will be returned to normal (admin-only) revision deletion.\n";
oversighting = 0;
}
if($("#revdelName").prop("checked") == $("#undelName").prop("checked"))
{
confirmString = confirmString + "-User name visibility won't change.\n";
}
else if($("#revdelName").prop("checked"))
{
if(oversighting == 0)
{
alert("we can't oversight and un-oversight edits at the same time!");
return false;
}
if(deleteString != "")
{
deleteString = deleteString + "|";
}
deleteString = deleteString + "user";
confirmString = confirmString + "-User name will be oversighted.\n";
oversighting = 1;
}
else
{
if(oversighting == 1)
{
alert("we can't oversight and un-oversight edits at the same time!");
return false;
}
if(deleteString != "")
{
deleteString = deleteString + "|";
}
deleteString = deleteString + "user";
confirmString = confirmString + "-User name will be returned to normal (admin-only) revision deletion.\n";
oversighting = 0;
}
if(deleteString == "")
{
alert("You didn't select any properties of the revisions to change!");
return false;
}
var summary = "";
//construct the revdel summary
if($("#wpRevDeleteReasonList").val() == "other")
{
if($("#wpReason").val() == "")
{
alert("You didn't select or write in an edit summary for the logs!");
return false;
}
summary = $("#wpReason").val();
}
else
{
summary = $("#wpRevDeleteReasonList").val();
if($("#wpReason").val() != "")
{
summary = summary + ": " + $("#wpReason").val();
}
}
confirmString = confirmString + "\nYour oversight summary is: "+ summary +"\n\nAre you sure you want to do this?";
if(confirm(confirmString))
{
var numCompleted = 0;
for (title in pageTitles)
{
var ajaxData;
ajaxData = {action:"revisiondelete",type:"revision",ids:pageTitles[title],reason:summary,hide:deleteString};
if(oversighting == 1)
{
ajaxData.suppress = "yes";
}
else if(oversighting == 0)
{
ajaxData.suppress = "no";
}
else
{
alert("Something went wrong, so we're going to abort without doing anything.");
}
api.postWithToken('csrf', ajaxData).done(function()
{
numCompleted++;
if(numCompleted == numTitles)
{
alert("modified " + revCount + " revision(s) successfully!");
return false;
}
});
}
}
return false;
}
)
}
});