Jump to content

User:Pyrospirit/scriptcontrol.js

From Wikipedia, the free encyclopedia
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.
/*

This is the location of a script I'm currently working on. The goal of the 
script is to allow users to enable and disable any user script at will from 
any page. Currently, this requires manual editing of your JavaScript page, 
which is impractical for frequent use.

The basic idea of the script is to set a cookie for each user script 
installed and determine whether to load the script or not based on the value 
of the cookie.

Once the script is complete, the installation should work roughly like this:
1) Install this script like usual.
2) Configure it with your other scripts using a format similar to this:
     function scriptControlConfig ()
     {
       scriptControlAddScript ( 'http://en.wikipedia.org/w/index.php?title=User:Example/script.js', 'Example script', true );
       scriptControlAddScript ( 'http://en.wikipedia.org/w/index.php?title=User:Someone/something.js', 'Some script', false );
     }
   This would have the first script labeled "Example script" and enabled by 
   default and the second script labeled "Some script" and disabled by default. 
   Of course, this could be later changed with a cookie without editing any 
   pages.
 
I am expecting to have a stable version completed... er... eventually.
 
*/

// <pre><nowiki>

var scriptControlVersion = '0.0.2'; // hacking around, mostly. Version 0.1 will be when it does something.

function scriptcontrolLink(){
addPortletLink ('p-personal', 'javascript:scriptcontrolpanel()', 'scripts', 'pt-scripts', 'Turn scripts on/off');
}

function scriptcontrol() {
alert('zo\'e, just testing out the portlet...');
}

$(scriptcontrolLink);

// </nowiki></pre>