User:MusikAnimal/scriptManager.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. |
This user script seems to have a documentation page at User:MusikAnimal/scriptManager. |
var scriptsToManage;
(function() {
var $html;
if (mw.config.get('skin') === "vector") {
$html = $("<nav class='mw-portlet vector-menu vector-menu-portal portal' role='navigation' id='p-enable-scripts' aria-labelledby='p-enable-scripts-label'></nav>");
$html.append("<label id='p-enable-scripts-label' class='vector-menu-heading'><span class='vector-menu-heading-label'>Enable scripts</span></label>");
$html.append("<div class='vector-menu-content'><ul class='vector-menu-content-list'></ul></div>");
} else if (mw.config.get('skin') === "vector-2022") {
$html = $("<div class='vector-main-menu-group vector-menu mw-portlet' role='navigation' id='p-enable-scripts' aria-labelledby='p-enable-scripts-label'></div>");
$html.append("<div id='p-enable-scripts-label' class='vector-menu-heading'><span class='vector-menu-heading-label'>Enable scripts</span></label>");
$html.append("<div class='vector-menu-content'><ul class='vector-menu-content-list'></ul></div>");
} else {
$html = $("<div class='generated-sidebar portlet' id='p-enable_scripts' role='navigation'></div>");
$html.append("<h3>Enable scripts</h3>");
$html.append("<div class='pBody'><ul></ul></div>");
}
var loadScript = function(e) {
mw.loader.load(e.data.src);
$(e.target).parent().remove();
};
if(scriptsToManage) {
$.each(scriptsToManage, function(script, src) {
var scriptName = mw.util.escapeIdForAttribute(script.replace(/[ \/]/g,"_")),
containerSelector = '#column-one';
$html.find("ul").append("<li><a href='javascript:' id='t-enablescript-"+scriptName+"'>"+script+"</a></li>");
if (mw.config.get('skin') === 'vector') {
containerSelector = '#mw-panel';
} else if (mw.config.get('skin') === 'vector-2022') {
containerSelector = '.vector-main-menu';
}
$(containerSelector).append($html);
$("#t-enablescript-"+scriptName).click({
script: script,
src: src
}, loadScript);
});
} else {
$html.find("ul").append("<li><a href='//en.wikipedia.org/wiki/User:MusikAnimal/scriptManager'>No scripts registered!</a></li>");
$(mw.config.get('skin') === "vector" || mw.config.get('skin') === "vector-2022" ? "#mw-panel" : "#column-one").append($html);
}
}());