User:Trialpears/sandbox/XFDloader.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. |
Documentation for this user script can be added at User:Trialpears/sandbox/XFDloader. |
/**
* XFDcloser sandbox Loader:
* On XFD pages, load the sandbox version of XFDcloser (after loading dependencies)
*/
/* jshint esversion: 5, laxbreak: true, undef: true, eqnull: true, maxerr: 900 */
/* globals window, $, mw, importScript, importStylesheet */
/* <nowiki> */
$.when(
// Resource loader modules
mw.loader.using([
'mediawiki.util', 'mediawiki.api', 'mediawiki.Title',
'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows',
'ext.gadget.libExtraUtil', 'ext.gadget.morebits'
]),
// Stylesheets
importStylesheet( 'MediaWiki:Gadget-XFDcloser.css' ),
// Page ready
$.ready
).then(function() {
var config = mw.config.get( [
'wgPageName',
'wgUserGroups'
] );
/* Quick checks that script should be running */
if ( /(?:\?|&)(?:action|diff|oldid)=/.test(window.location.href) ) {
// Page is in edit, history, diff, or oldid mode
return;
}
if (
config.wgUserGroups.indexOf('extendedconfirmed') === -1 &&
config.wgUserGroups.indexOf('sysop') === -1
) {
// User is not extendedconfirmed or sysop
return;
}
var xfdpage_regex = /(Articles_for_deletion\/|Miscellany_for_deletion|User:Cyberbot_I\/AfD's_requiring_attention|Wikipedia:WikiProject_Deletion_sorting\/(?!(Flat|Compact)$)|(Categories|Files|Templates|Redirects)_for_discussion(?!\/(Working|Holding_cell|Speedy)))(?!\/?(?:Administrator_instructions|Common_outcomes)$)/;
if ( !xfdpage_regex.test(config.wgPageName) ) {
// Current page is not an XfD page;
return;
}
/* Load the version 3 sandbox script */
// importScript("User:Evad37/XFDcloser/sandbox.js");
/* Load the version 4 sandbox script */
importScript("User:Trialpears/sandbox/XFDcloser.js");
});
/* </nowiki> */