User:Chlod (test)/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:Chlod (test)/common.css. |
document.addEventListener("redwarn:preInit", function() { console.log("redwarn preinit called"); });
mw.hook( 'wikipage.content' ).add( function () { console.log("wikipage.content", arguments) } );
mw.hook( 'wikipage.diff' ).add( function () { console.log("wikipage.diff", arguments) } );
// common.js link at hotbar.
$("#p-personal #pt-logout").before("<li id=\"pt-commonjs\"><a href=\"/wiki/Special:MyPage/common.js\">common.js</a></li>");
$("#p-personal #pt-logout").before("<li id=\"pt-rwjs\"><a href=\"/wiki/Special:MyPage/redwarnConfig.js\">redwarnConfig.js</a></li>");
// Add (nr) 'no redirect' links after redirects.
mw.hook( 'wikipage.content' ).add( function ( $el ) {
$el.find( '.mw-redirect' ).each( function (i, e) {
var sub = document.createElement("sub");
sub.append("(");
var link = document.createElement("a");
var url = new URL(e.getAttribute("href"), window.location.href);
url.searchParams.set("redirect", "no");
link.setAttribute("href", url.toString());
link.innerText = "nr";
sub.appendChild(link);
sub.append(")");
e.insertAdjacentElement("afterend", sub);
} );
} );
// GTT
mw.loader.load( '/w/index.php?title=User:Chlod/Scripts/GoToTitle.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Chlod/Scripts/GoToTitle.js]]
mw.util.addPortletLink(
'p-tb',
"/wiki/Special:MyPage/common.js",
'common.js', 't-common.js', 'Open your common.js'
);
// importScript("User:RedWarn/.js"); // [[User:RedWarn/]]
// importScript("User:RedWarn/beta.js"); // [[User:RedWarn/beta]]
//importScript("User:TheresNoTime/linkThings.js");
// mw.loader.load("http://localhost:45000/coordinator.js");
// mw.loader.load("http://localhost:45000/cte-core.js");
// RedWarn for Testing
// mw.loader.load("http://localhost:45991/build.php");
// RedWarn
window.rw_debug = true;
// Ultraviolet
// mw.loader.load("http://localhost:45991/ultraviolet.js");
// importScript("User:10nm/beta.js");
mw.loader.load("http://localhost:45000/deputy.js");
// mw.loader.load("http://localhost:45000/deputy-ante.js");
// mw.loader.load("http://localhost:45000/deputy-ccrf-loader.js");
// mw.loader.load( '/w/index.php?title=User:Chlod/Scripts/Deputy.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Chlod/Scripts/Deputy.js]]
if ( window.location.search.indexOf( '?deputy-noisolation=1' ) === -1 ) {
mw.hook( 'infringementAssistant.preload' ).add( function() {
window.InfringementAssistant.wikiConfig.ia.rootPage.set(new mw.Title("User:Chlod/Scripts/Deputy/tests/Problems"));
} );
var ccrfOverrides = {
cci: {
rootPage: "User:Chlod/Scripts/Deputy/tests",
requestsHeader: "Requests",
requestsTemplate: "{{subst:CCI-request\n|user = $1\n|evidence = $2\n}}"
},
ccrf: {
pageDeletionFilters: {
source: '([#:]G12)|(copyright\\s*(infringement|vio(lation)?|policy))', flags: 'gi'
},
revisionDeletionFilters: {
source: '([#:]RD1)|(copyright\\s*(infringement|vio(lation)?|policy))', flags: 'gi'
},
warningFilters: {
source: '<!--\\s*Template:uw-(.+?)\\s*-->', flags: 'gi'
}
}
};
mw.hook( 'ccrf.preload' ).add( function() {
window.deputyWikiConfigOverride = ccrfOverrides;
} );
mw.hook( 'ccrf.loader.preload' ).add( function() {
window.deputyWikiConfigOverride = ccrfOverrides;
} );
mw.hook( 'deputy.preload' ).add( function () {
// Replace resource root to load local development assets
window.deputy.resourceRoot = { type: "url", url: new URL( "http://localhost:45000/" ) };
window.deputy.getWikiConfig().then( function (wikiConfig) {
// Override root pages for testing
wikiConfig.core.dispatchRoot.set(new URL("https://deputy.toolforge.org/"));
wikiConfig.cci.rootPage.set(new mw.Title( 'User:Chlod/Scripts/Deputy/tests' ));
wikiConfig.ia.rootPage.set(new mw.Title("User:Chlod/Scripts/Deputy/tests/Problems"));
wikiConfig.ia.hideTemplate.reset();
wikiConfig.ia.hideTemplateBottom.reset();
} );
} );
}
function loadModule( src ) {
var e = document.createElement( 'script' );
e.setAttribute( 'type', 'module' );
e.setAttribute( 'src', src );
document.head.appendChild( e );
}
// Userscript development
// loadModule( 'http://localhost:5173/@vite/client' );
// loadModule( 'http://localhost:5173/@id/mediawiki-userscript/hmr-listener' );
// loadModule( 'http://localhost:5173/src/main.ts' );