MediaWiki:Gadget-XFDcloser.js
From Test Wiki
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.
/* _______________________________________________________________________________
* | |
* | === WARNING: GLOBAL GADGET FILE === |
* | Changes to this page affect many users. |
* | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
* |_______________________________________________________________________________|
*
* Built from source code at GitHub repository [https://github.com/wikimedia-gadgets/xfdcloser]
* All changes should be made in the repository, otherwise they will be lost.
*
* To update this script from github, you must have a local repository set up. Then
* follow the instructions at [https://github.com/wikimedia-gadgets/xfdcloser/blob/master/README.md]
*
* XFDcloser: close deletion discussions at XfD venues, including actions to implement closes; see [[WP:XFDC]]
* Author: Evad37
* Licencing and attribution: [[WP:XFDC#Licencing and attribution]]
*/
/* jshint esversion: 5, esnext:false, laxbreak: true, undef: true, eqnull: true, maxerr: 3000 */
/* globals console, document, window, $, mw, OO */
/* <nowiki> */
(function(){
// Check if on a non-existent article/file/portal (to unlink backlinks)
var isNonexistentPage = mw.config.get("wgArticleId") === 0;
var isUnlinkableNamespace = [
0, // Article
6, // File
100 // Portal
].indexOf(mw.config.get("wgNamespaceNumber")) !== -1;
var isUnlinkablePage = isNonexistentPage && isUnlinkableNamespace;
// Check for edit, history, diff, or oldid mode
if ( !isUnlinkablePage && /(?:\?|&)(?:action|diff|oldid)=/.test(window.location.href) ) {
return;
}
// XFDcloser options
var options;
try {
options = JSON.parse(mw.user.options.get("userjs-xfdc")) || {};
} catch(e) {
options = {};
}
// Check if on an XfD page
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)$)/;
var isXfdPage = xfdpage_regex.test(mw.config.get("wgPageName"));
// Load for XfD pages as well as unlinkable pages
var shouldLoadScript = isXfdPage || isUnlinkablePage;
if ( !shouldLoadScript ) {
return;
}
mw.loader.load( options && options.beta ? "ext.gadget.XFDcloser-core-beta" : "ext.gadget.XFDcloser-core");
})();
/* </nowiki> */