MediaWiki:Gadget-XFDcloser.js

/* _______________________________________________________________________________ * |                                                                               | * |                     === 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 * 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 * * XFDcloser: close deletion discussions at XfD venues, including actions to implement closes; see WP:XFDC * Author: Evad37 * Licencing and attribution: WP:XFDC */ /* jshint esversion: 5, esnext:false, laxbreak: true, undef: true, eqnull: true, maxerr: 3000 */ /* globals console, document, window, $, mw, OO */ /* */ (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"); }); /* */