User:Lil' Miss Rarity/global.js

importScriptPage("User:Prince(ss)_Platinum/vda.js", "c"); //importScriptPage("User:Lil' Miss Rarity/DRR.js", "c"); //importScriptPage("User:Lil' Miss Rarity/BRT.js", "c"); importScriptPage("WHAM/code.js", "dev"); importScriptPage("AjaxRC/code.js", "dev"); importScriptPage("AjaxUndo/code.js", "dev"); /*''*/

/**************************************************************************/ //* Wiki tools - A set of misc. wiki tools. //* //* Copyright 2013 Benjamin Williams <[ Lil' Miss Rarity ]> //* //* This program is free software: you can redistribute it and/or modify //* it under the terms of the GNU General Public License as published by //* the Free Software Foundation, either version 3 of the License, or //* (at your option) any later version. //* //* This program is distributed in the hope that it will be useful, //* but WITHOUT ANY WARRANTY; without even the implied warranty of //* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //* GNU General Public License for more details. //*                                                                  //* You should have received a copy of the GNU General Public License //* along with this program. If not, see . /**************************************************************************/

var wikitools = {

wgVars: [ mw.config.get("wgPageName"), mw.config.get("wgUserName"), mw.config.get("wgServer"), mw.util.wikiScript("api"), mw.user.tokens.values.editToken ],

init: function { switch(wikitools.wgVars[0]) { case "Special:BrokenRedirects": wikitools.brt; break; case "Special:DoubleRedirects": wikitools.drr; break; default: break; }   },    //Tag broken redirects brt: function { function tag(page, i) { $.ajax({               url: wikitools.wgVars[3],                data: {                    action: "edit",                    title: page,                    text: "",                    summary: "Tagging for deletion (broken redirect)",                    format: "json",                    token: wikitools.wgVars[4]                },                dataType: "JSON",                type: "POST",                success: function {                     $("ol.special li:eq(" + i + ")").children("a:eq(1)").text("done!");                },                fail: function {                    $("ol.special li:eq(" + i + ")").children("a:eq(1)").text("failed!");                }            }); }       $("ol.special li").each(function(i) {            var node = document.createElement("a");                node.textContent = "marker";                node.addEventListener("click", function { var page = $("ol.special li:eq(" + i + ")").children("a:eq(0)").text; tag(page, i); });           $(this).children("a:eq(1)").attr("href", "javascript:void(0)").html($(node));        }); } };

$(document).ready(function {

wikitools.init; });