User:MC10/common.js

This is the current revision of this page, as edited by MC10 (talk | contribs) at 05:23, 20 March 2018 (remove blanked script). The present address (URL) is a permanent link to this version.

(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/**
 *
 * MC10's Scripts
 * Linkback: [[User:MC10/common.js]]
 *
 * This is a compilation of all of the scripts that I use.
 * Feel free to copy my common.js or any of the scripts here.
 * Some scripts are commented out, so they are disabled.
 * Of course, you can enable them in your skin.js file.
 *
 * To access your skin.js file, follow this link:
 * http://en.wikipedia.org/wiki/Special:MyPage/skin.js
 *
 * @user MC10
 * @skin All
 *
 */

(function() {
    "use strict";

    /**
     * Variables and functions
     */
    // Cache mw.config.get calls
    const mwConf = mw.config.get(["wgCanonicalSpecialPageName",
    	"wgNamespaceNumber", "wgRestrictionEdit", "wgTitle"]);

    // Re-define deprecated functions
    function importScript(script) {
        return mw.loader.load(mw.util.wikiScript("index") + "?" + $.param({
        	title: mw.util.wikiUrlencode(script),
        	action: "raw",
        	ctype: "text/javascript",
        }));
    }

    /**
     * Named scripts
     */
    // [[User:Lupin/popups.js]]
    window.popupFixRedirs = true;
    window.popupRedlinkRemoval = true;
    window.popupFixDabs = true;
    window.popupRedirAutoClick = "wpDiff";
    window.popupStructure = "menus";
    window.popupAdminLinks = true;
    //window.removeTitles = false;

    if (Array.isArray(mwConf.wgRestrictionEdit) &&
    		!mwConf.wgRestrictionEdit.includes("sysop") &&
        	mwConf.wgNamespaceNumber !== 8) {

        // [[User:Js/ajaxPreview]]
        importScript("User:Js/ajaxPreview.js");

        window.ajaxPreviewPos = "bottom";
        window.ajaxPreviewScrollTop = true;
        window.ajaxPreviewExec = function(previewArea) {
        	// Code to execute after each preview update
            if (window.setupTooltips) {
                window.setupTooltips(previewArea);
                previewArea.ranSetupTooltipsAlready = false;
            }
        };
    }

    // [[User:Js/watchlist]]
    if (mwConf.wgCanonicalSpecialPageName === "Watchlist") {
        importScript("User:Js/watchlist.js");
    }

    /**
     * Useful scripts
     */
    importScript("User:Dr pda/prosesizebytes.js"); // [[User:Dr pda/prosesizebytes.js]]
    if ((mwConf.wgNamespaceNumber === 4 || mwConf.wgNamespaceNumber === 5)
            && mwConf.wgTitle.includes("Articles for creation/")) {
        importScript("User:Timotheus Canens/afchelper4.js"); // Yet another AfC helper script v4.
    }

    /**
     * My scripts
     */
    importScript("User:MC10/UsefulTabs.js"); // Useful tabs ("purge", "count", etc.)
    importScript("User:MC10/rollbackSummary.js"); // Gracenotes' rollback summary script, modified
    if (mwConf.wgNamespaceNumber === 0) {
        importScript("User:MC10/stubtagtab.js"); // Stub tags
    }
})();