Skip to content

Instantly share code, notes, and snippets.

@Gautier
Created March 2, 2013 20:29
Show Gist options
  • Save Gautier/5073134 to your computer and use it in GitHub Desktop.
Save Gautier/5073134 to your computer and use it in GitHub Desktop.
An old jetpack experiment
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