User:Inductiveload/common-fallback.js

"use strict";

// IIFE used when including as a user script (to allow debug or config) // Default gadget use will get an IIFE wrapper as well (function($, mw) {

console.log("Fallback JS loaded");

// Useful to avoid loading scripts when not useful var _ns = mw.config.get("wgNamespaceNumber"); var _action = mw.config.get("wgAction"); var _title = mw.config.get("wgTitle"); var _isEdit = (_action === "submit" || _action === "edit"); var _isMain = _ns === 0; var _isUser = _ns === 2; var _isTemplate = _ns === 10; var _isPage = _ns === 104; var _isIndex = _ns === 106; var _isAuthor = _ns === 102;

// skip index page "do you want to create" page if (_isIndex && mw.config.get("wgRevisionId") === 0) { $( document ).ready(function {   var $link = $('#noarticletext_edit a');    if ($link.length > 0) {      window.location = $($link[0]).attr("href");    }  }); }

/* Auto submit when purging pages */ if (mw.config.get("wgAction") === "purge") { $('button[type="submit"]').click; }

}(jQuery, mediaWiki));