User:SD0001/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:SD0001/common.css. |
/* jshint maxerr: 999 */
mw.loader.load('http://localhost:5500');
// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 7
if(!/\bnocache=\b/.test(location.href)){let e=mw.config.values,t="text/javascript",r="text/css",n=(n,o,i)=>(n=n.replace(/special:mypage/i,"User:"+e.wgUserName),$.get("https://"+o+"/w/api.php?titles="+n+"&origin=*&format=json&formatversion=2&uselang=content&maxage=86400&smaxage=86400&action=query&prop=revisions|info&rvprop=content&rvlimit=1&inprop=protection").then(e=>{let a=e.query.pages[0];if(!a.missing){if(2!==a.ns&&8!==a.ns&&!a.protection.find(e=>"edit"===e.type&&"sysop"===e.level))return $.Deferred().reject('Refused to load "'+n+'"@'+o+": unprotected page");let l=a.revisions[0].content;if(i&&i!==t||"javascript"!==a.contentmodel){if(i!==r||"css"!==a.contentmodel)return $.Deferred().reject('Refused to load "'+n+'"@'+o+": content type mismatch");mw.loader.addStyleTag(l)}else document.head.appendChild(document.createElement("script")).innerHTML=l}})),o=e.wgServerName,i=e=>{let t=/^(?:(?:https:)?\/\/(.*))?\/w\/index.php/.exec(e),r=/\btitle=([^=?&]*)/.exec(e);return t&&r&&/\baction=raw\b/.test(e)&&/\bctype=/.test(e)?[r[1],t[1]||o]:null};window.importScript=e=>{n(encodeURIComponent(e),o,t)},window.importStyleSheet=e=>{n(encodeURIComponent(e),o,r)};let a=mw.loader.load;mw.loader.load=function(e,t){let r=i(e);r?n(r[0],r[1],t):a.apply(mw.loader,[...arguments])};let l=mw.loader.getScript;mw.loader.getScript=function(e){let r=i(e);return r?n(r[0],r[1],t):l.apply(mw.loader,[...arguments])}}
var onMobile = /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (mw.config.get('skin') === 'vector-2022') {
$('meta[name=viewport]').prop('content', 'width=device-width');
}
$.ready.then(function() {
// When redirected to a section, show the "Redirected from" text at the top of the section too, and add section name at the top
if( $('.mw-redirectedfrom')[0] && window.location.hash ) {
var hash = window.location.hash, sectionName = hash.slice(1).replace(/_/g, ' ');
var redirectedFromSpan = $('.mw-redirectedfrom')[0];
$('#' + $.escapeSelector(hash.slice(1))).parent().after(
$(redirectedFromSpan).clone().attr('id', 'contentSub2')
);
redirectedFromSpan.innerHTML = redirectedFromSpan.innerHTML
.replace(/\)$/, ' to section <a href="' + hash + '">' + decodeURIComponent(sectionName) + '</a>)');
}
if (mw.config.get('skin') === 'vector') {
// Make the subject page button not follow the redirect
if ($("#p-namespaces a")[0].className.includes('mw-redirect')) {
$("#p-namespaces a")[0].href += '?redirect=no';
}
}
// reduce font size of code on mobile
// disable syntax highlightening of large code blocks as it causes mobile browser to crash
if (onMobile) {
mw.loader.addStyleTag('.mw-highlight pre { font-size: 70%; }');
$('pre').each(function() {
if (this.childElementCount > 2000) {
this.textContent = this.textContent;
}
});
}
});
// pop-ups
window.popupFixDabs = true;
window.popupDabsAutoClick = 'wpPreview';
// MoreMenu
mw.hook('moremenu.ready').add(function (config) {
MoreMenu.addLink(
'page',
'ORES',
'https://ores.wikimedia.org/scores/enwiki/?models=articlequality|articletopic|draftquality|drafttopic&revids=' + mw.config.get('wgRevisionId')
);
});
// dark-mode-toggle
window.wpDarkModeAutoToggle = true;
mw.loader.using('mediawiki.util').then(function() {
if (mw.util.getParamValue('action') === 'history') {
importScript('User:Ale_jrb/Scripts/userhist.js'); // [[User:Ale_jrb/Scripts/userhist.js]]
importScript('User:SD0001/hide-reverted-edits.js'); // Backlink: [[User:SD0001/hide-reverted-edits.js]]
} else if (mw.util.getParamValue('diff') || mw.config.get('wgPageName') === 'Special:ComparePages') {
importScript('User:Enterprisey/diff-permalink.js'); // [[User:Enterprisey/diff-permalink.js]]
}
});
if (mw.config.get('wgNamespaceNumber') === 0) {
if (!onMobile) {
importScript('User:Titodutta/scripts/SearchHelper.js'); // Backlink: [[User:Titodutta/scripts/SearchHelper.js]]
}
// also imported below for draftspace
importScript('User:Headbomb/unreliable.js'); // [[User:Headbomb/unreliable.js]]
} else if (mw.config.get('wgNamespaceNumber') % 2 === 1 || mw.config.get('wgCanonicalNamespace') === 'Project') {
importScript('User:Jackmcbarn/editProtectedHelper.js'); // [[User:Jackmcbarn/editProtectedHelper.js]]
if (mw.config.get('wgCanonicalNamespace') === 'Project') {
if (mw.config.get('wgPageName').startsWith('Wikipedia:Requested_articles')) {
importScript('User:Enterprisey/req-helper.js'); // [[User:Enterprisey/req-helper.js]]
} else if (mw.config.get('wgPageName') === 'Wikipedia:Bots/Requests_for_approval/request') {
importScript('User:Enterprisey/easy-brfa.js'); // [[User:Enterprisey/easy-brfa.js]]
} else if (mw.config.get('wgPageName') === 'Wikipedia:AutoWikiBrowser/Script') {
importScript('User:Joeytje50/JWB.js/load.js'); // [[User:Joeytje50/JWB.js/load.js]]
} else if (mw.config.get('wgPageName') === 'Wikipedia:Requests_for_undeletion') {
importScript('User:SD0001/RFUD-helper.js'); // [[User:SD0001/RFUD-helper.js]]
}
}
} else if (['Template', 'Module'].includes(mw.config.get("wgCanonicalNamespace"))) {
importScript('User:Enterprisey/sync-template-sandbox.js'); // [[User:Enterprisey/sync-template-sandbox.js]]
importScript('User:SD0001/sandbox4.js'); // [[User:Jackmcbarn/advancedtemplatesandbox.js]], [[User:SD0001/sandbox4.js]]
} else if (mw.config.get('wgCanonicalNamespace') === 'Draft') {
importScript('User:SD0001/draft-sort-burst.js'); // [[User:SD0001/draft-sort-burst.js]]
draft_sort_burst_watchlistOption = 'watch';
importScript('User:SD0001/edits-since-decline.js'); // Backlink: [[User:SD0001/edits-since-decline.js]]
importScript('User:Headbomb/unreliable.js'); // also imported for mainspace
} else if (mw.config.get('wgCanonicalNamespace') === 'Category') {
importScript('User:קיפודנחש/cat-a-lot.js'); // Backlink: [[User:קיפודנחש/cat-a-lot.js]]
importScript('User:SD0001/shortdescs-in-category.js'); // Backlink: [[User:SD0001/shortdescs-in-category.js]]
importScript('User:Nardog/CatChangesViewer.js'); // Backlink: [[User:Nardog/CatChangesViewer.js]]
} else if (mw.config.get('wgCanonicalNamespace') === 'Special') {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Watchlist') {
importScript('User:SD0001/watchlist-update-title.js'); // Backlink: [[User:SD0001/watchlist-update-title.js]]
} else if (mw.config.get('wgCanonicalSpecialPageName') === 'Whatlinkshere') {
mw.loader.load('//www.wikidata.org/w/index.php?title=MediaWiki:Linkscount.js&action=raw&ctype=text/javascript'); // [[wikidata:MediaWiki:Linkscount.js]]
} else if (mw.config.get('wgPageName') === 'Special:RecentChanges') {
importScript('User:SD0001/RC-links-new-tab.js'); // Backlink: [[User:SD0001/RC-links-new-tab.js]]
} else if (mw.config.get('wgCanonicalSpecialPageName') === 'Log') {
importScript('User:Amorymeltzer/logSwap.js'); // Backlink: [[User:Amorymeltzer/logSwap.js]]
} else if (mw.config.get('wgPageName') === 'Special:PrivateSandbox') {
importScript('User:SD0001/private-sandbox.js'); // Backlink: [[User:SD0001/private-sandbox.js]]
}
} else if (mw.config.get('wgPageName') === 'MediaWiki:Gadgets-definition') {
mw.loader.load('//en.wiktionary.org/w/index.php?title=User:Erutuon/scripts/gadgets-definition.js&action=raw&ctype=text/javascript'); // [[wikt:User:Erutuon/scripts/gadgets-definition.js]]
}
var codePage = ['javascript', 'json', 'css', 'sanitized-css', 'Scribunto'].includes(mw.config.get('wgPageContentModel'));
var templatePage = mw.config.get('wgCanonicalNamespace') === 'Template' && !mw.config.get('wgPageName').endsWith('/doc');
if (codePage || templatePage) {
$.ready.then(function() {
$('#mw-script-doc .mbox-text').append(" Install using <code>importScript('"+mw.config.get('wgPageName').replace(/_/g, ' ')+"');</code>");
});
importScript('User:Danski454/codeEditWindowSize.js'); // Backlink: [[User:Danski454/codeEditWindowSize.js]]
window.codeEditorHeight = 661;
importScript('User:Nardog/CodeEditorAssist.js'); // Backlink: [[User:Nardog/CodeEditorAssist.js]]
mw.loader.load('//en.wiktionary.org/w/index.php?title=MediaWiki:Gadget-CodeLinks.js&action=raw&ctype=text/javascript'); // [[wikt:MediaWiki:Gadget-CodeLinks.js]]
}
importScript('User:Ale_jrb/Scripts/csdhelper.js'); // [[User:Ale_jrb/Scripts/csdhelper.js]]
importScript('User:SD0001/deleted-metadata-link.js'); // [[User:SD0001/deleted-metadata-link.js]]
importScript('User:SD0001/quickViewDeleted.js'); // [[User:SD0001/quickViewDeleted.js]]
importScript('User:Evad37/rater.js'); // [[User:Evad37/rater.js]]
importScript('User:SD0001/DYK-helper.js'); // Backlink: [[User:SD0001/DYK-helper.js]]
importScript('User:SD0001/StubSorter.js'); // Backlink: [[User:SD0001/StubSorter.js]]
importScript('User:SD0001/W-Ping.js'); // Backlink: [[User:SD0001/W-Ping.js]]
// importScript('User:SD0001/easy-merge.js'); // Backlink: [[User:SD0001/easy-merge.js]]
importScript('User:BrandonXLF/QuickEdit.js'); // Backlink: [[User:BrandonXLF/QuickEdit.js]]
importScript('User:Jack who built the house/convenientDiscussions.js'); // [[commons:User:Jack who built the house/Convenient Discussions]]
// Remove own comment marker in CD
mw.hook('convenientDiscussions.pageReadyFirstTime').add(() => {
mw.loader.addStyleTag(`:root { --cd-comment-own-marker-color: unset; }`);
});