Thành viên:NgocAnMaster/Gadget-XFDcloser.js

Chú ý: Sau khi lưu thay đổi trang, bạn phải xóa bộ nhớ đệm của trình duyệt để nhìn thấy các thay đổi. Google Chrome, Firefox, Internet ExplorerSafari: Giữ phím ⇧ Shift và nhấn nút Reload/Tải lại trên thanh công cụ của trình duyệt. Để biết chi tiết và hướng dẫn cho các trình duyệt khác, xem Trợ giúp:Xóa bộ nhớ đệm.

/*  _______________________________________________________________________________
 * |                                                                               |
 * |                     === 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 = /(Biểu_quyết_xóa_bài\/|Biểu_quyết_xóa_không_gian_tên|Biểu_quyết_xóa_(thể_loại|tập_tin|bản_mẫu|trang_đổi_hướng)(?!\/(Working|Holding_cell|Xóa_nhanh)))(?!\/?(?:Hướng_dẫn_cho_bảo_quản_viên|Hệ_quả_thường_thấy)$)/;
	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> */