|
|
| Line 1: |
Line 1: |
| /* _______________________________________________________________________________ | | /* XFDcloser loader: loads the discussion-closing tool on deletion-discussion pages and on pages where a deletion-discussion notice needs to be removed. */ |
| * | |
| | (function () { |
| * | === WARNING: GLOBAL GADGET FILE === |
| | var isNonexistentPage = mw.config.get("wgArticleId") === 0; |
| * | Changes to this page affect many users. |
| | var isUnlinkableNamespace = [0, 6, 100].indexOf(mw.config.get("wgNamespaceNumber")) !== -1; |
| * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
| | var isUnlinkablePage = isNonexistentPage && isUnlinkableNamespace; |
| * |_______________________________________________________________________________|
| | if (!isUnlinkablePage && /(?:\?|&)(?:action|diff|oldid)=/.test(window.location.href)) { |
| *
| | return; |
| * 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.
| | var xfdpageRegex = /(Articles_for_deletion\/|Miscellany_for_deletion|(Categories|Files|Templates|Redirects)_for_discussion(?!\/(Working|Holding_cell|Speedy)))(?!\/\/?(?:Administrator_instructions|Common_outcomes)$)/; |
| *
| | var isXfdPage = xfdpageRegex.test(mw.config.get("wgPageName")); |
| * To update this script from github, you must have a local repository set up. Then
| | var shouldLoadScript = isXfdPage || isUnlinkablePage; |
| * follow the instructions at [https://github.com/wikimedia-gadgets/xfdcloser/blob/master/README.md]
| | if (!shouldLoadScript) { |
| *
| | return; |
| * XFDcloser: close deletion discussions at XfD venues, including actions to implement closes; see [[WP:XFDC]]
| | } |
| * Author: Evad37
| | mw.loader.load("ext.gadget.XFDcloser-core"); |
| * 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|(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("ext.gadget-XFDcloser-core");
| |
| })(); | | })(); |
| /* </nowiki> */
| |
|
| |
| /* TEMP TRACE - revert after test */
| |
| (function(){window.__xfdcLoaderTrace={afterLoaderCoreState:mw.loader.getState("ext.gadget.XFDcloser-core"), loaderState:mw.loader.getState("ext.gadget.XFDcloser"), pn:mw.config.get("wgPageName")};})();
| |
|
| |
| /* TEMP TRACE2 */
| |
| (function(){try{var pn=mw.config.get('wgPageName');var ns=mw.config.get('wgNamespaceNumber');var aid=mw.config.get('wgArticleId');var isNon=aid===0;var isUnNs=[0,6,100].indexOf(ns)!==-1;var isUn=isNon&&isUnNs;var actRe=/(?:\?|&)(?:action|diff|oldid)=/.test(window.location.href);var re=/(Articles_for_deletion\/|Miscellany_for_deletion|(Categories|Files|Templates|Redirects)_for_discussion(?!\/(Working|Holding_cell|Speedy)))(?!\/\/?(?:Administrator_instructions|Common_outcomes)$)/;var isXfd=re.test(pn);window.__xfdcTrace2={pn:pn,ns:ns,aid:aid,isNon:isNon,isUnNs:isUnNs,isUn:isUn,actRe:actRe,isXfd:isXfd,shouldLoad:isXfd||isUn,href:window.location.href,coreState:mw.loader.getState('ext.gadget.XFDcloser-core')};}catch(e){window.__xfdcTrace2={err:e.message};}})();
| |
|
| |
| /* TEMP FIX-TEST */
| |
| (function(){var re=/(Articles_for_deletion\/|Miscellany_for_deletion|(Categories|Files|Templates|Redirects)_for_discussion(?!\/(Working|Holding_cell|Speedy)))(?!\/\/?(?:Administrator_instructions|Common_outcomes)$)/;if(re.test(mw.config.get('wgPageName'))){window.__xfdcFixTest='loading-core';mw.loader.load('ext.gadget.XFDcloser-core');}})();
| |
/* XFDcloser loader: loads the discussion-closing tool on deletion-discussion pages and on pages where a deletion-discussion notice needs to be removed. */
(function () {
var isNonexistentPage = mw.config.get("wgArticleId") === 0;
var isUnlinkableNamespace = [0, 6, 100].indexOf(mw.config.get("wgNamespaceNumber")) !== -1;
var isUnlinkablePage = isNonexistentPage && isUnlinkableNamespace;
if (!isUnlinkablePage && /(?:\?|&)(?:action|diff|oldid)=/.test(window.location.href)) {
return;
}
var xfdpageRegex = /(Articles_for_deletion\/|Miscellany_for_deletion|(Categories|Files|Templates|Redirects)_for_discussion(?!\/(Working|Holding_cell|Speedy)))(?!\/\/?(?:Administrator_instructions|Common_outcomes)$)/;
var isXfdPage = xfdpageRegex.test(mw.config.get("wgPageName"));
var shouldLoadScript = isXfdPage || isUnlinkablePage;
if (!shouldLoadScript) {
return;
}
mw.loader.load("ext.gadget.XFDcloser-core");
})();