User:Dave Braunschweig/lintHint.js

/// User:PerfektesChaos/js/lintHint/r.js /// 2017-12-08 PerfektesChaos@de.wikipedia /// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA) /// (function (mw, $) {   "use strict";    var Version = 2.12, Signature = "lintHint", HINT = { doc: "en:User:PerfektesChaos/js/" + Signature, errors: ["bogus-image-options", "deletable-table-tag", "fostered", "html5-misnesting", "ignored-table-attr", "misc-tidy-replacement-issues", "misnested-tag", "missing-end-tag", "missing-start-tag", "mixed-content", "multi-colon-escape", "multiline-html-table-in-list", "multiple-unclosed-formatting-tags", "obsolete-tag", "pwrap-bug-workaround", "self-closed-tag", "stripped-tag", "tidy-font-bug", "tidy-whitespace-bug", "unclosed-quotes-in-heading"], idRev: 0, last: true, later: false, launch: false, launched: false, layer: false, lazy: false, live: false, ltr: true, using: ["mediawiki.api", "mediawiki.api.messages", "mediawiki.util"], $body: false, $page: false, $textarea: false }, API = { Api: false, errors: false, scream: false, service: "transform/wikitext/to/lint" }, BOX = { bgc: "FFFF00", bgcErr: "FFE4E1", bgcOk: "ADFF2F", bgcRun: "C0C0C0", boc: "808080", fgc: "000000", fgcRun: "A0A0A0", swift: false, $box: false, $collapsed: false, $failure: false, $null: false, $other: false, $pagename: false, $swift: false, $tbody: false, $table: false, $top: false }, EDIT = { listen: false, live: false, $source: false }, GUIDER = { last: false, live: false, reTrim: false, using: ["jquery.textSelection", "mediawiki.ui.button", "mediawiki.ui.input"], $pagename: false }, LINTER = {}, PREGO = { app: false, signature: "preferencesGadgetOptions" }; HINT.texts = { "desc": { "en": "Show LintErrors analysis live.", "de": "Zeige LintErrors-Analyse live." },       "domain": { "en": "en.wikipedia.org", "de": "de.wikipedia.org" }, "howTo": { "en": "Fill balanced wikitext into first input area and press adjacent submit button, or enter page name into second input field.", "de": "Füge ausgeglichenen Wikitext in das obere Eingabefeld ein, oder einen Seitennamen in das untere, und betätige die jeweilige Schaltfläche." },       "mark": { "en": "select problem in source text", "de": "Problem im Quelltext selektieren" }, "noPage": { "en": "Wikitext page not found", "de": "Wikitext-Seite nicht gefunden" }, "other": { "en": "Future problems detected.", "de": "Zukünftige Probleme detektiert." }   };

function face { if (!HINT.$body) { HINT.$body = $("body"); HINT.ltr = ($("html").attr("dir") !== "rtl"); }   }

function fair(action) { if (mw.config.get("skin") !== "minerva") { if (action) { mw.loader.using("jquery.tablesorter", action); } else { HINT.using.push("jquery.tablesorter"); }       }    }

function features(apply) { var i, live; if (typeof apply === "object" && apply) { if (typeof apply.rooms === "object" && apply.rooms && typeof apply.rooms.length === "number") { live = false; for (i = 0; i < apply.rooms.length; i++) { if (apply.rooms[i] === HINT.nsn) { live = true; break; }               }            } else if (typeof apply.rooms === "string" && apply.rooms === "*") { live = true; } else { live = false; }           if (typeof apply.later === "boolean") { HINT.later = apply.later; }           if (typeof apply.launch === "boolean") { HINT.launch = apply.launch; }           if (typeof apply.layer === "boolean") { HINT.layer = apply.layer; }           if (typeof apply.lazy === "boolean") { HINT.lazy = apply.lazy; if (HINT.lazy) { BOX.flat; }           }            if (live && !HINT.last) { live = false; if (typeof apply.oldid === "boolean" && apply.oldid) { live = true; }           }            if (live && !HINT.live) { HINT.live = true; if (HINT.launch && !HINT.launched) { mw.loader.using(HINT.using, API.feed); } else { mw.loader.using(HINT.using, BOX.feed); }           } else if (HINT.live && !live) { BOX.flat; }       }    }

function first { var listen, live, re, s;       HINT.signature = "ext.gadget." + Signature; if (mw.loader.getState(HINT.signature) !== "ready") { mw.loader.state(HINT.signature, "ready"); switch (mw.config.get("wgAction")) { case "view": HINT.nsn = mw.config.get("wgNamespaceNumber"); switch (HINT.nsn) { case -1: s = mw.config.get("wgCanonicalSpecialPageName"); switch (s) { case "Blankpage": s = mw.config.get("wgTitle"); if (s.indexOf("/" + Signature) > 0) { GUIDER.first; }                                   listen = true; break; case "LintErrors": fair(LINTER.first); break; }                           break; case 0: case 2: case 4: case 6: case 10: case 12: case 14: case 100: case 102: HINT.live = true; default: HINT.idRev = mw.config.get("wgRevisionId"); s = window.location.search; if (HINT.idRev <= 0) { live = false; } else if (s) { re = "\\b(diff|history|printable)="; re = new RegExp(re); live = !re.test(s); if (live) { if (s.indexOf("&oldid=") > 0) { if (mw.config.get("wgCurRevisionId") !== HINT.idRev) { HINT.last = false; HINT.live = false; }                                   }                                }                            } else { live = true; }                   }                    break; case "edit": case "submit": case "parsermigration-edit": EDIT.live = true; HINT.nsn = mw.config.get("wgNamespaceNumber"); if (HINT.nsn === 0) { HINT.live = true; }                   HINT.using.push("jquery.textSelection"); live = true; break; }           if (live) { s = mw.config.get("wgPageContentModel"); live = (s === "wikitext"); listen = live; }           if (listen) { mw.hook(Signature + ".config").add(features); }           if (live) { PREGO.feed; fair; if (HINT.live) { mw.loader.using(HINT.using, BOX.feed); }           }            HINT.pub = { doc: "" + HINT.doc + "", type: Signature, vsn: Version }; mw.hook(Signature + ".ready").fire(HINT.pub); }   }

API.fault = function (jqXHR, textStatus, errorThrown) { if (textStatus) { switch (typeof textStatus) { case "object": if (typeof textStatus.textStatus === "string") { API.scream = textStatus.textStatus; } else { API.scream = ""; }                   if (typeof textStatus.exception === "string" && textStatus.exception) { API.scream = API.scream + " (" + textStatus.exception + ")"; }                   break; case "string": API.scream = textStatus; break; }       }        if (errorThrown) { if (API.scream) { API.scream = API.scream + " -- Error: "; }           API.scream = API.scream + errorThrown; }       if (!API.scream) { API.scream = "???"; }       if (typeof window.console === "object" && typeof window.console.log === "function") { window.console.log(Signature + " * " + API.scream); if (typeof textStatus === "object" && textStatus && typeof window.console.dir === "function") { window.console.dir(textStatus); }       }        API.errors = false; mw.hook("wikipage.content").add(BOX.fault); };

API.feed = function (access) { var w = { action: "query", prop: "revisions" }; if (typeof access === "string") { API.single = access; }       if (HINT.nsn < 0) { w.rvprop = "content|contentmodel"; } else { w.rvprop = "content"; if (!HINT.idRev) { HINT.idRev = mw.config.get("wgRevisionId"); }           HINT.launched = true; }       if (HINT.idRev) { w.revids = HINT.idRev; } else if (API.single) { w.titles = API.single; } else { w = false; }       if (w) { if (!API.Api) { API.Api = new mw.Api; }           API.Api.get(w).done(API.feeder).fail(API.fault); }   };

API.feeder = function (arrived) { var id, q, s, w;       if (typeof arrived === "object" && typeof arrived.query === "object" && typeof arrived.query.pages === "object") { q = arrived.query.pages; for (id in q) { q = q[id]; if (q && q.revisions) { q = q.revisions[0]; if (typeof q.contentmodel !== "string" || q.contentmodel === "wikitext") { s = q["*"]; if (/\{\{/.test(s)) { w = { action: "expandtemplates", prop: "wikitext|volatile", text: s }; if (API.single) { w.title = API.single; }                           if (HINT.idRev) { w.revid = HINT.idRev; }                           if (w) { API.Api.post(w).done(API.fed).fail(API.fault); }                       } else { API.fire(s); }                   }                }                break; }       }        if (!s) { if (PREGO.app) { s = PREGO.app.translation(HINT.texts.noPage); } else { s = HINT.texts.noPage.en; }           if (API.single) { s = s + " * " + API.single; }           API.fault(null, "Missing", s); }   };    API.fed = function (arrived) { if (typeof arrived === "object" && typeof arrived.expandtemplates === "object" && typeof arrived.expandtemplates.wikitext === "string") { API.fire(arrived.expandtemplates.wikitext); }   };

API.fine = function (arrived) { var start; if (typeof arrived === "object" && arrived && typeof arrived.length === "number" && arrived.length) { API.errors = arrived; start = "fill"; } else { API.errors = false; start = "flat"; }       API.scream = false; mw.hook("wikipage.content").add(BOX[start]); };

API.fire = function (ask) { var local = (typeof ask === "string"); if (typeof API.query !== "object") { API.query = { dataType: "json" };           API.site = window.location.protocol + "//" + window.location.hostname + "/"; if (local) { API.site = API.site + "api/rest_v1/" + API.service; API.query.type = "POST"; API.query.url = API.site; }       }        if (local) { API.query.data = { wikitext: ask }; }       $.ajax(API.query).done(API.fine).fail(API.fault); };

BOX.factory = function ($area) { var $a, $e; if (HINT.live) { HINT.$page = $area; if (BOX.$box) { if (BOX.$failure) { BOX.$failure.hide; }               BOX.$box.show; } else { face; BOX.$box = $(" "); $e = $(" "); if (HINT.nsn < 0) { $a = $(" "); } else { $a = $(""); $a.attr({ href: "/wiki/Special:Blankpage/" + Signature, target: Signature }); }               $a.css({ "font-weight": "bold", "font-size": "larger" }) .text(Signature + "@PerfektesChaos"); $e.append($a).css({ "float": (HINT.ltr ? "left" : "right") }); BOX.$box.append($e).attr({ id: Signature }).css({                   "background-color": "#" + BOX.bgc, "border-color": "#" + BOX.boc,                    "border-style": "solid", "border-width": "1px",                    "color": "#" + BOX.fgc, "margin-bottom": "1em",                    "padding": "0.5em"                }); $e = $(" "); $e.click(BOX.flip).css({                   "color": "#FF0000", "float": (HINT.ltr ? "right" : "left"),                   "font-weight": "bolder"                }).css("margin-" + (HINT.ltr ? "right" : "left"), "6px").text("X"); BOX.$box.append($e); BOX.focus(BOX.$box); }       } else { BOX.flat; }   };

BOX.fault = function ($area) { BOX.flat; BOX.factory($area); if (API.scream && BOX.$box) { if (BOX.$table) { BOX.$table.hide; }           if (!BOX.$failure) { BOX.$failure = $(" "); BOX.$failure.css({                   "clear": "both", "color": "#FF0000",                    "font-weight": "bold"                }); BOX.$box.append(BOX.$failure); }           BOX.$failure.text(API.scream).show; }       if (GUIDER.$pagename) { GUIDER.$pagename.hide; }   };

BOX.feed = function { if (HINT.launch && !HINT.launched) { API.feed; } else { mw.hook("wikipage.content").add(BOX.flip); }   };

BOX.fill = function ($area) { var i, req, $th, $thead, $tr; BOX.factory($area); if (BOX.$collapsed) { BOX.$collapsed.hide; }       if (BOX.$null) { BOX.$null.hide; }       if (BOX.$box) { if (BOX.$table) { if (HINT.$textarea) { if (GUIDER.last) { BOX.$swift.hide; } else { BOX.$swift.show; }               }                BOX.$tbody.empty; BOX.filler; } else { BOX.$table = $(" "); $thead = $(" "); if (HINT.nsn < 0) { BOX.$pagename = $(" "); BOX.$pagename.css({ "font-weight": "normal", "white-space": "nowrap" }); BOX.$table.append(BOX.$pagename); }               $tr = $(" "); $th = $(" "); $th.text("lint"); $tr.append($th); $th = $(" "); $th.text("+"); $tr.append($th); if (HINT.$textarea) { BOX.$swift = $(" "); BOX.$swift.data("sort-type", "number").text("⇓"); mw.hook(PREGO.signature + ".ready").add(BOX.flag); if (GUIDER.last) { BOX.$swift.hide; }                   $tr.append(BOX.$swift); }               $thead.append($tr); BOX.$tbody = $(" "); BOX.$table.addClass("wikitable").attr({ id: Signature + "-table" }) .append($thead, BOX.$tbody).css({ "clear": "both" }); if (HINT.errors.length > 1 || HINT.nsn < 0) { BOX.$table.addClass("sortable"); }               BOX.$box.append(BOX.$table); req = []; for (i = 0; i < HINT.errors.length; i++) { req.push("linter-category-" + HINT.errors[i]); }               if (!API.Api) { API.Api = new mw.Api; }               API.Api.loadMessagesIfMissing(req).done(BOX.filler).fail(API.fault); }           if (BOX.$pagename) { GUIDER.from(BOX.$pagename); }       }    };

BOX.filler = function { var n = 0, e, i, k, par, s, $e, $e2, $e3, $td, $tr; for (i = 0; i < API.errors.length; i++) { e = API.errors[i]; s = "linter-category-" + e.type; if (mw.messages.exists(s)) { s = mw.message(s).text; } else if (HINT.later) { s = e.type; } else { s = false; }           if (s) { $tr = $(" "); $td = $(" "); $td.css({ "background-color": "#" + BOX.bgcErr }); $td.text(s); $tr.append($td); $td = $(" "); $td.css({ "background-color": "#FFFFFF" }); if (typeof e.params === "object") { par = e.params; if (Version < 0) { for (s in par) { if (s !== "child" && s !== "items" && s !== "name" && s !== "root") { console.log(s, par) }                       }                    }                    if (typeof par.name === "string") { $td.text(par.name); } else if (typeof par.root === "string" && typeof par.child === "string") { $e = $(" "); $e.text(par.root); $e2 = $(" "); $e2.css({ "padding-left": "1em", "padding-right": "1em" }) .html("&gt;"); $e3 = $(" "); $e3.text(par.child); $td.append($e, $e2, $e3).css({ "white-space": "nowrap" }); } else if (typeof par.items === "object" && typeof par.items.length === "number") { for (k = 0; k < par.items.length; k++) { $e = $(" "); $e.css({ "margin-right": "6px", "white-space": "nowrap" }) .text(par.items[k]); $td.append($e); }                   }                }                $tr.append($td); if (HINT.$textarea && !GUIDER.last && typeof e.dsr === "object" && e.dsr && typeof e.dsr[0] === "number" && typeof e.dsr[1] === "number") { $td = $(" "); $td.click(BOX.find).data("range", e.dsr).data("sort-value", i)                       .text(" ↓ "); if (typeof BOX.swift === "string") { $td.attr({ title: BOX.swift }); }                   $tr.append($td); }               BOX.$tbody.append($tr); n++; }       }        if (n) { if (BOX.$other) { BOX.$other.hide; }           if (n > 1 && typeof BOX.$table.tablesorter === "function") { BOX.$table.tablesorter; }           BOX.$table.show; } else { BOX.$table.hide; if (BOX.$other) { BOX.$other.show; } else { if (PREGO.app) { BOX.future; } else { mw.hook(PREGO.signature + ".ready").add(BOX.future); }           }        }    };

BOX.find = function (event) { var $item = $(event.target), range = $item.data("range"); HINT.$textarea.focus.textSelection("setSelection", { start: range[0], end: range[1] }); };

BOX.flag = function (application) { if (application) { PREGO.app = application; }       BOX.swift = PREGO.app.translation(HINT.texts.mark); BOX.$swift.attr({ title: BOX.swift }); };

BOX.flat = function ($area, alive) { if ($area && !HINT.$page) { HINT.$page = $area; }       if (BOX.$box) { BOX.$box.hide; }       if (BOX.$collapsed && !alive && !EDIT.live) { BOX.$collapsed.hide; }       if (EDIT.live) { if (!alive) { BOX.flip; }       } else if (!API.errors && !API.scream && HINT.live) { if (API.single && GUIDER.$pagename) { if (BOX.$null) { BOX.$null.hide; }               GUIDER.from(GUIDER.$pagename); } else if (BOX.$null) { if (HINT.lazy) { BOX.$null.hide; } else { BOX.$null.show; }           } else if (!HINT.lazy && HINT.launched && HINT.$page) { face; BOX.$null = $(" "); BOX.$null.attr({ id: Signature + "-null" }).css({                   "background-color": "#" + BOX.bgcOk,                    "clear": "both", "color": "#" + BOX.fgc,                    "float": (HINT.ltr ? "right" : "left"), "font-size": "smaller",                   "padding": "3px"                }).text(Signature); if (!GUIDER.live) { BOX.$null.attr({ title: Signature + "@PerfektesChaos " + Version }); }               BOX.focus(BOX.$null); }       } else if (BOX.$null) { BOX.$null.hide; }   };

BOX.flip = function ($area) { if ($area && !HINT.$page) { HINT.$page = $area; }       face; BOX.flat($area, true); if (BOX.$collapsed) { BOX.$collapsed.attr({ disabled: false }).show; } else { BOX.$collapsed = $(" "); BOX.$collapsed.attr({ id: Signature + "-collapsed" }).click(BOX.full).css({               "clear": (HINT.ltr ? "right" : "left"),               "float": (HINT.ltr ? "right" : "left"), "margin-bottom": "3px",               "padding": "2px"            }).text(Signature); if (!GUIDER.live) { BOX.$collapsed.attr({ title: Version }); }           BOX.focus(BOX.$collapsed); }       BOX.$collapsed.css({ "background-color": "#" + BOX.bgc, "color": "#" + BOX.fgc }); if (EDIT.live && !API.errors) { EDIT.fine; }       if (GUIDER.$pagename) { GUIDER.$pagename.hide; }   };

BOX.focus = function ($apply) { var $e; if (!BOX.$top) { BOX.$top = $(" "); BOX.$top.attr({ id: Signature + "-top" }).css({               "clear": "both",                "width": "100%"            }); $e = $(" "); $e.css({ "clear": "both" }); HINT.$page.prepend(BOX.$top, $e); }       BOX.$top.prepend($apply); };

BOX.full = function { if (HINT.live) { if (BOX.$box) { if (EDIT.live) { API.errors = false; } else { BOX.$collapsed.hide; }               if (API.errors) { BOX.$box.show; } else { BOX.$box.hide; }           }            if (!API.errors) { BOX.$collapsed.attr({ disabled: true }).css({ "background-color": "#" + BOX.bgcRun, "color": "#" + BOX.fgcRun }); }           if (!API.single && !GUIDER.live) { API.single = mw.config.get("wgTitle"); }           if (EDIT.live) { if (!EDIT.$source) { EDIT.$source = HINT.$page.find("#wpTextbox1"); if (!EDIT.$source.length) { BOX.$collapsed.hide; EDIT.live = false; }               }                if (EDIT.live) { EDIT.listen = false; API.fire(EDIT.$source.val); HINT.$textarea = EDIT.$source; }           } else { HINT.launch = true; API.feed(API.single); }       } else { BOX.$collapsed.hide; }   };

BOX.future = function (application) { var $e; if (application) { PREGO.app = application; }       if (PREGO.app) { $e = $(" "); $e.css({               "border-color": "#" + BOX.boc, "border-style": "solid",                "border-width": "1px", "padding": "0.4em"            }) .html(PREGO.app.translation(HINT.texts.other)); BOX.$other = $(" "); BOX.$other.attr({ id: Signature + "-future" }).css({               "clear": "both",                "padding-bottom": "1em", "padding-top": "1em"            }) .append($e); BOX.$box.append(BOX.$other); }   };

EDIT.fine = function { if (EDIT.$source) { EDIT.listen = true; EDIT.$source.focusin(EDIT.focus); BOX.$collapsed.css({ "background-color": "#" + BOX.bgcOk }); }   };

EDIT.focus = function { if (EDIT.listen) { BOX.$collapsed.css({ "background-color": "#" + BOX.bgc }); EDIT.listen = false; }   };

LINTER.fire = function ($area) { var $table = $area.find(".TablePager"); if ($table.length) { if (typeof $table.tablesorter === "function") { $table.tablesorter; }           if (HINT.layer) { LINTER.reEdit = new RegExp("([?&]action=)edit(&.+)?$"); $table.find("a").each(LINTER.further); }       }    };

LINTER.first = function { if (mw.config.get("wgTitle").indexOf("/") > 0) { mw.hook("wikipage.content").add(LINTER.fire); }   };

LINTER.further = function (any, a) { var $a = $(a), s = $a.attr("href"); if (s.indexOf("action=edit") > 0) { $a.attr("href", s.replace(LINTER.reEdit, "$1parsermigration-edit$2")); }   };

GUIDER.find = function { var s = GUIDER.$input.val; GUIDER.fired; GUIDER.last = true; if (!GUIDER.reTrim.test(s)) { API.single = s;           API.feed(API.single); }   };

GUIDER.finish = function (application) { var $e = $(" "); PREGO.app = application; GUIDER.$desc.html(PREGO.app.translation(HINT.texts.desc)); $e.css({ "clear": "both", "margin-top": "8em" }) .html(PREGO.app.translation(HINT.texts.howTo)); HINT.$page.append($e); $e = $(""); $e.attr({ href: "https://" + PREGO.app.translation(HINT.texts.domain) + "/wiki/User:PerfektesChaos/js/" + Signature, target: Signature }).text(GUIDER.$doc.text); GUIDER.$doc.text("").append($e); };

GUIDER.fire = function { var s = GUIDER.$textarea.val; GUIDER.fired; GUIDER.last = false; if (!GUIDER.reTrim.test(s)) { API.single = false; API.fire(s); HINT.launched = true; }   };

GUIDER.fired = function { GUIDER.flat; if (!GUIDER.reTrim) { GUIDER.reTrim = new RegExp("^\\s*$"); }   };

GUIDER.first = function { var i;       PREGO.feed; for (i = 0; i < GUIDER.using.length; i++) { HINT.using.push(GUIDER.using[i]); }       fair; mw.loader.load(HINT.using); HINT.live = true; GUIDER.live = true; mw.hook("wikipage.content").add(GUIDER.furnish); };

GUIDER.flat = function { if (BOX.$box) { BOX.$box.hide; }       if (BOX.$collapsed) { BOX.$collapsed.hide; }       if (BOX.$null) { BOX.$null.hide; }       if (GUIDER.$pagename) { GUIDER.$pagename.hide; }   };

GUIDER.foreign = function { var req = ["general-form-reset", "go"], i;       if (!API.Api) { API.Api = new mw.Api; }       for (i = 0; i < HINT.errors.length; i++) { req.push("linter-category-" + HINT.errors[i]); }       API.Api.loadMessagesIfMissing(req).done(GUIDER.form).fail(API.fault); };

GUIDER.form = function { var submit = mw.message("go").text, $b = $(" "), $div = $(" "), $x = $(" "); $x.css({ "color": "#FF0000", "font-weight": "bolder" }) .text("X"); $b.addClass("mw-ui-button mw-ui-progressive").click(GUIDER.fire).css({ "color": "#FFFFFF" }) .text(submit); GUIDER.$formText.append($b); $b = $(" "); $b.addClass("mw-ui-button").append($x).attr({ type: "reset" }) .click(GUIDER.flat).css({ "float": (HINT.ltr ? "right" : "left") }); GUIDER.$formText.append($b); $b = $(" "); $b.addClass("mw-ui-button mw-ui-progressive").click(GUIDER.find).css({ "color": "#FFFFFF" }, { "float": (HINT.ltr ? "right" : "left") }).text(submit); $div.append($b); $b = $(" "); $b.addClass("mw-ui-button").append($x.clone).attr({ type: "reset" }) .click(GUIDER.flat).css({ "float": (HINT.ltr ? "right" : "left") }); $div.append($b).css({ "float": (HINT.ltr ? "right" : "left") }); GUIDER.$formPage.append($div); mw.hook(PREGO.signature + ".ready").add(GUIDER.finish); };

GUIDER.from = function ($at) { var $e; if (API.single) { $e = $at.children; if (!$e.length) { $e = $(""); $e.attr({ target: "_blank" }); $at.append($e); }           $e.attr({ href: mw.util.getUrl(API.single) }).text(API.single); $at.show; } else { $at.hide; }   };

GUIDER.furnish = function ($area) { var $v = $("head"), $e = $v.find("title"); $e.remove; $e = $(" "); $e.text(Signature); $v.prepend($e); HINT.$page = $area; HINT.$page.empty; face; $v = HINT.$body.find("#firstHeading,#section_0"); if (!$v.length) { $v = $("h1"); }       $v.eq(0).text(Signature); $v = $(" "); $v.css({ "clear": "both" }); GUIDER.$doc = $(" "); GUIDER.$doc.text(Signature + "@PerfektesChaos"); $e = $(" "); $e.css({ "font-size": "smaller" }).css("margin-" + (HINT.ltr ? "left" : "right"), "2em").text(Version); $v.append(GUIDER.$doc, $e); GUIDER.$desc = $(" "); GUIDER.$desc.css({ "font-size": "111%" }).text(" "); $v.append($v, GUIDER.$desc); HINT.$page.append($v); GUIDER.$formText = $(" "); GUIDER.$textarea = $(" "); GUIDER.$textarea.addClass("mw-ui-input").attr({ name: "wikitext" }) .css({               "margin-top": "2em", "max-width": "100%",                "width": "100%"            }); GUIDER.$formText.append(GUIDER.$textarea); GUIDER.$formPage = $(" "); GUIDER.$formPage.css({ "clear": "both", "margin-top": "3em" }); GUIDER.$input = $(" "); GUIDER.$input.addClass("mw-ui-input").attr({ maxlength: 255, name: "pagename", size: 50, type: "text" }).css({           "float": (HINT.ltr ? "left" : "right"),           "width": "auto", "max-width": "auto"        }); GUIDER.$formPage.append(GUIDER.$input); HINT.$page.append(GUIDER.$formText, GUIDER.$formPage); GUIDER.$pagename = $(" "); GUIDER.$pagename.attr({ id: Signature + "-pagename" }).css({           "background-color": "#" + BOX.bgcOk,            "float": (HINT.ltr ? "left" : "right"), "margin-bottom": "1em",           "padding": "4px"        }).hide; HINT.$page.prepend(GUIDER.$pagename); HINT.$textarea = GUIDER.$textarea; mw.loader.using(HINT.using, GUIDER.foreign); };

PREGO.feed = function { var s = "ext.gadget." + PREGO.signature; if (mw.loader.getState(s) !== "ready") { mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/" + PREGO.signature + "/r.js&bcache=1&maxage=604812&action=raw&ctype=text/javascript"); }   };

first; }(window.mediaWiki, window.jQuery));