User:Lil' Miss Rarity/global.js

importScriptPage("User:Prince(ss)_Platinum/vda.js", "c"); importScriptPage("User:Lil' Miss Rarity/qt.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");

$.getScript("https://raw.github.com/DoctorWhooves/Main/master/batch/BatchRedlinks.js"); /*''*/

/**************************************************************************/ //* Wiki tools a misc. set of wiki tools for automation. //* //* 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 = "mark";                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));        }); },   //Resolves double redirects drr: function { function resolve(page, redirect, i) { $.ajax({               url: wikitools.wgVars[3],                data: {                    action: "edit",                    title: page,                    text: redirect,                    summary: "Resolving redirect",                    format: "json",                    token: wikitools.wgVars[4]                },                dataType: "JSON",                type: "POST",                success: function {                    $("ol.special li:eq(" + i + ")").children("a:eq(4)").text(" (done!)");                },                fail: function {                    $("ol.special li:eq(" + i + ")").children("a:eq(4)").text(" (failed!)");                }            }); }       $("ol.special li").each(function(i) {            var node = document.createElement("a");                node.textContent = " (repair)";                node.id = "drr-" + i;                node.addEventListener("click", function { var nodes = []; $(this).parent.find("a").each(function {                       nodes.push($(this).text);                    }); var foo = nodes[0]; var bar = nodes[3]; resolve(foo, bar, i); });           $(this).append($(node));           }); } };

$(document).ready(function {

wikitools.init; });