User:Daniel Quinlan/common.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Daniel Quinlan/common.css. |
class Start {
constructor() {
this.delayed = [];
}
load(script) {
if (script.startsWith('[[') && script.endsWith(']]')) {
script = script.slice(2, -2);
}
mw.loader.load('/w/index.php?title=' + script + '&action=raw&ctype=text/javascript');
}
delay(script, option = false, path = '#') {
if (option) {
const id = 'load-' + option.toLowerCase().replace(/\W+/g, '-');
path = path !== '#' ? '/wiki/' + path : path;
mw.util.addPortletLink('p-tb', path, option, id);
if (path === '#') {
$('#' + id).click(event => {
event.preventDefault();
this.load(script);
});
} else if (window.location.pathname === path) {
this.load(script);
}
} else {
this.delayed.push(script);
}
}
controls() {
const $vectorPageTools = $('#vector-page-tools');
if ($vectorPageTools.length) {
const $newButton = $('<button class="vector-show-controls-button">more</button>');
$vectorPageTools.find('.vector-pinnable-header-unpin-button').after($newButton);
$newButton.click(event => {
const toggled = document.body.classList.toggle('show-infrequent-controls');
$newButton.text(toggled ? 'less' : 'more');
if (toggled && this.delayed.length) {
this.delayed.forEach(script => this.load(script));
this.delayed = [];
}
});
}
const userPage = $('.vector-user-links #pt-userpage-2 a');
if (userPage.length) {
userPage.attr('href', userPage.attr('href').replace('/User:', '/User_talk:')).removeAttr('title');
}
}
}
const start = new Start();
start.load('[[User:Daniel Quinlan/Scripts/Clock.js]]');
if (mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgAction') !== 'view' || window.location.search) {
start.load('[[User:Daniel Quinlan/Scripts/UserHighlighterAlpha.js]]');
}
if (mw.config.get('wgNamespaceNumber') % 2 !== 0 || mw.config.get('wgNamespaceNumber') === 4) {
start.load('[[User:Daniel Quinlan/Scripts/Vanilla.js]]');
}
start.controls();
start.delay('[[User:Writ Keeper/Scripts/massRollback.js]]');
start.delay('[[User:Daniel Quinlan/Scripts/CitationGenerator.js]]');
if (mw.config.get('wgAction') === 'history' || mw.config.get('wgRelevantPageName') === 'Special:Log') {
start.delay('[[User:Daniel Quinlan/Scripts/HideBots.js]]');
}
start.delay('[[User:Joeytje50/JWB.js]]', 'JS Wiki Browser', 'Wikipedia:AutoWikiBrowser/Script');
start.delay('[[User:Headbomb/unreliable.js]]', 'Unreliable sources');
if (mw.config.get('wgPageName').includes('Wikipedia:Sockpuppet_investigations')) {
start.load('[[User:GeneralNotability/spihelper.js]]');
}
if (mw.config.get('wgNamespaceNumber') === -1 && ['Blankpage', 'AbuseLog', 'AbuseFilter'].includes(mw.config.get('wgCanonicalSpecialPageName'))) {
start.load('[[User:Suffusion of Yellow/FilterDebugger.js]]');
}
if ([0, 118].includes(mw.config.get('wgNamespaceNumber'))) {
start.delay('[[User:Epicgenius/ArticleQuality.js]]', 'Article quality');
}