User:Ilmari Karonen/edittoolstest.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. |
![]() | Documentation for this user script can be added at User:Ilmari Karonen/edittoolstest. |
/*
TEST OF JAVASCRIPT EDITTOOLS
To try out this feature, add the following lines to your monobook.js:
importScript("User:Ilmari Karonen/edittoolstest.js");
window.testJsEdittools = true;
To deploy this feature sitewide, the code below should be copied to [[MediaWiki:Common.js]],
while the code at [[User:Ilmari Karonen/edittools.js]] should be moved to [[MediaWiki:Edittools.js]].
After 30 days have passed (to allow time for browser caches to purge), the #editpage-specialchars
div and everything in it in [[MediaWiki:Edittools]] should be replaced with:
<div id="editpage-specialchars" class="edittools-version-0001"></div>
During the 30-day interval between initial and full deployment (while the class name still has "test"
in it), the code may be tested simply by setting "window.testJsEdittools = true". It should be safe
to run this script more than once: it will only work the first time, after that it will have removed
the #editpage-specialchars div and so will no longer do anything.
*/
if (wgAction == 'edit' || wgAction == 'submit') addOnloadHook(function () {
var placeholder = document.getElementById("editpage-specialchars");
if (!placeholder || window.noDefaultEdittools) return;
var match = /(?:^| )edittools-version-(\d+)(?: |$)/.exec(placeholder.className);
if (!match && window.testJsEdittools)
match = /(?:^| )edittools-version-(test\d+)(?: |$)/.exec(placeholder.className);
if (!match) return;
var url = wgScript + '?title=User:Ilmari_Karonen/edittools.js&action=raw&ctype=text/javascript&nocache=' + match[1];
// var url = wgScript + '?title=MediaWiki:Edittools.js&action=raw&ctype=text/javascript&nocache=' + match[1];
if (window.importScriptURI) {
mw.loader.load(url);
} else {
// while waiting for a scap...
var scriptElem = document.createElement( 'script' );
scriptElem.setAttribute( 'src' , url );
scriptElem.setAttribute( 'type' , 'text/javascript' );
document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
}
});