User:Daniel Quinlan/common.js

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 = $('more '); $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'); }