Created
March 2, 2013 20:29
-
-
Save Gautier/5073134 to your computer and use it in GitHub Desktop.
An old jetpack experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jetpack.statusBar.append({ | |
html: "<input type='button' value='Disable Javascript' id='jsEnabler' />", | |
onReady: function(widget){ | |
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(""); | |
var jsEnabled = prefs.getBoolPref("javascript.enabled"); | |
var button = $(widget).find("#jsEnabler"); | |
if(!jsEnabled) button.val("Enable Javascript"); | |
$(widget).click(function(){ | |
if(jsEnabled) { | |
jetpack.notifications.show( "Disabling Javascript" ); | |
prefs.setBoolPref("javascript.enabled", false); | |
jsEnabled = prefs.getBoolPref("javascript.enabled"); | |
button.val("Enable Javascript"); | |
}else{ | |
jetpack.notifications.show( "Enabling Javascript" ); | |
prefs.setBoolPref("javascript.enabled", true); | |
jsEnabled = prefs.getBoolPref("javascript.enabled"); | |
button.val("Disable Javascript"); | |
} | |
}); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment