User:Alien333/common.js
Appearance
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
The accompanying .css page for this skin is at User:Alien333/common.css. |
/* global $, mw, importScript */
"use strict";
importScript("User:Alien333/poemise.js");
importScript("User:Alien333/nobr.js");
importScript("User:Alien333/clean.js");
importScript("User:Alien333/dab.js");
importScript("User:Alien333/cuts.js");
importScript("User:Alien333/transclude.js");
importScript("User:Alien333/rhalt.js");
importScript("User:Alien333/addtpp.js");
importScript("User:Alien333/pagenum.js");
importScript("w:User:Ahecht/Scripts/TemplateSearch.js");
mw.loader.load('//en.wikisource.org/w/index.php?title=User:Inductiveload/popups reloaded.js&action=raw&ctype=text/javascript'); // these look cool
mw.loader.load("//en.wikisource.org/w/index.php?title=User:Inductiveload/popups_reloaded.css&action=raw&ctype=text/css", 'text/css');
mw.loader.using(['mediawiki.util'], () => {
$(() => {
if (mw.config.get('wgCanonicalNamespace') == '' && mw.config.get("wgPageName").includes("/") && $("#firstHeading")[0].innerHTML.includes("Creating")) { // too specific stuff
mainspacetricks();
} else if (mw.config.get("wgCanonicalNamespace") == "Page" && ["edit", "submit"].includes(mw.config.get("wgAction"))) {
$(".editButtons").on("click", (e) => pos(e) );
$("head").append("<style>.cmbb-digi{color:red;}</style>");
}
});
});
function mainspacetricks() {
var l = $('#wpTextbox1').val();
var name = mw.config.get("wgPageName").split("/")[0].replaceAll(/[\)\(]/g, "").replaceAll("_", " "); // again, my own naming conventions for indexes
if (name.slice(0,6) == "Poems ") {
l = l.replace("[[../]]", "[[../|Poems]]");// I usually do works titled Poems (author name), this keeps me from having to add |Poems for every single subpage
}
l = l.replace("| previous = \n", "| previous = [[../\n");
l = l.replace("| next = \n", "| next = [[../\n");
if (!l.includes("<pages")) {
l = l + '<pages index="'+name +'.djvu" include= />';
}
$("#wpTextbox1").val(l).trigger("input");
}
let pos = (e) => {
if ($("#wpTextbox1").val().split("\n").some(x => (x.replaceAll("'''", "''").replaceAll("''", "\t").replaceAll(/[^\t]/g, "").length % 2 == 1))) {
e.preventDefault();
alert("Invalid italic/bold detected.");
} else {
let l = $("#wpTextbox1").val();
let s = l.replaceAll(/\{di([A-Z])\}/g, "{{di|$1|image="+/*/^(.*?)\./.exec(mw.config.get("wgTitle"))[1]*/"IllumPoemsAllen"+"$1.png|imgsize=x86px}}");
$("#wpTextbox1").val(s).trigger("input");
}
};