Jump to content

User:Ponor/wAwB.js

From Wikipedia, the free encyclopedia
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.
/*
 * wAwB – An in-browser application for automated editing of wiki pages.
 * Features:  customizable regex or JavaScript search-and-replace rules, 
 * custom JavaScript pre/post-processing functions and function libraies,
 * granular protection or targeting of different parts of wikitext,
 * a full-fledged CodeMirror editor, and options to move, delete, and protect pages.
 * Author: [[User:Ponor]]
 * Documentation: [[User:Ponor/wAwB]]
 * License: GNU General Public License (GPL)
 */

// This file creates a portlet link for the worker script [[User:Ponor/wAwB-worker.js]]
// and loads the script at the following page: [[Special:Blankpage/wAwB]]
(function() {
    var WORKER_SCRIPT_URL = "//en.wikipedia.org/w/index.php?title=User:Ponor/wAwB-worker.js";

    var isToolPage = mw.config.get('wgCanonicalSpecialPageName') === "Blankpage" && 
                     mw.config.get('wgPageName').slice(-5) === "/wAwB";

    if (isToolPage) {
        mw.loader.load(WORKER_SCRIPT_URL + "&action=raw&ctype=text/javascript");
        
    } else {
        $.when(mw.loader.using(['mediawiki.util']), $.ready).then(function() {
            mw.util.addPortletLink(
                'p-tb', 
                mw.util.getUrl('Special:BlankPage/wAwB'), 
                window.wa_editIn || 'Edit in wAwB', 
                'pt-wAwB', 
                window.wa_toolTip || 'Automated editing gadget'
            );
        });
    }
})();