Home  

Random  

Nearby  



Log in  



Settings  



Donate  



About Wikipedia  

Disclaimers  



Wikipedia





User:Hilst/Scripts/scriptManager.js





User page  

Talk  



Language  

Watch  

View source  


< User:Hilst
 


Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/** 
 * scriptManager, based on [[:en:User:MusikAnimal/scriptManager.js]] by [[User:MusikAnimal]]
 */

$( document ).ready( function () { 
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function () {
 "use strict";
 
 if (mw.config.get('skin') === 'timeless') {
  var portlet = mw.util.addPortlet("p-enable-scripts", "Enable scripts");
  $(portlet).insertAfter('#p-tb');
 } else {
  if ($('#p-coll-print_export').length > 0) {
   mw.util.addPortlet("p-enable-scripts", "Enable scripts", "#p-coll-print_export");
  } else {
   mw.util.addPortlet("p-enable-scripts", "Enable scripts", "#p-lang");
  }
 }

 var loadScript = function(e) {
  mw.loader.load(e.data.src); // Load the script
                              // TODO: implement error handling
  mw.notify(`${e.data.script} has been enabled.`, {title: "scriptManager", type: "success"});
  $(`#t-enablescript-${e.data.scriptName}`).remove();
 };
 
  if (window.scriptsToManage) {
  $.each(scriptsToManage, function(script, src) {
   var scriptName = script.replace(/ /g,"_"); 

   mw.util.addPortletLink("p-enable-scripts", "javascript:", script, `t-enablescript-${scriptName}`, `Enable ${script} for this page`);

   // If a script has been clicked, pipe it to loadScript
   $(`#t-enablescript-${scriptName}`).click({
    scriptName: scriptName,
    script: script,
    src: src
   }, loadScript);
  });
  } else {
  mw.util.addPortletLink("p-enable-scripts", "en.wikipedia.org/wiki/User:Hilst/Scripts/scriptManager", "No scripts registered!");
  }
});
}());

Retrieved from "https://en.wikipedia.org/w/index.php?title=User:Hilst/Scripts/scriptManager.js&oldid=1230400128"
 



Last edited on 22 June 2024, at 13:58  


Languages

 



This page is not available in other languages.
 

Wikipedia


This page was last edited on 22 June 2024, at 13:58 (UTC).

Content is available under CC BY-SA 4.0 unless otherwise noted.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Terms of Use

Desktop