Created
January 20, 2017 20:39
-
-
Save Infocatcher/26802f739e72cd919ce9aecff0708196 to your computer and use it in GitHub Desktop.
Turn off extensions signatures in Firefox (see comments in the code)
This file contains hidden or 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
// Turn off extensions signatures in Firefox | |
// Use at your own risk! | |
// Usage: | |
// Start browser with rights to write into his install directory (run as administrator) | |
// devtools.chrome.enabled = true (in about:config) | |
// Open Scratchpad: Shift+F4 (Tools - Web-Developer - Scratchpad) | |
// Set: Environment - Browser | |
// Then paste following code and press Run, browser will be restarted, than enjoy | |
// Hack: https://forum.mozilla-russia.org/viewtopic.php?pid=720001#p720001 | |
// This code: https://gist.github.com/Infocatcher/26802f739e72cd919ce9aecff0708196 | |
var bak = ".no-signatures.bak"; | |
// Disable signatures | |
var hackPath = OS.Path.join(OS.Constants.Path.libDir, "no-signatures.js"); | |
var prefPath = OS.Path.join(OS.Constants.Path.libDir, "defaults", "pref", "no-signatures-prefs.js"); | |
var textEncoder = new TextEncoder(); | |
var arr = textEncoder.encode( | |
`// | |
try { | |
Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {}) | |
.eval("SIGNED_TYPES.clear();"); | |
} | |
catch(e) { | |
Components.utils.reportError(e); | |
}` | |
); | |
OS.File.writeAtomic(hackPath, arr) | |
.then(null, Components.utils.reportError); | |
arr = textEncoder.encode( | |
`pref("general.config.filename", "no-signatures.js"); | |
pref("general.config.obscure_value", 0);` | |
); | |
OS.File.writeAtomic(prefPath, arr) | |
.then(null, Components.utils.reportError); | |
// Turn on already disabled extensions | |
var dataPath = OS.Path.join(OS.Constants.Path.profileDir, "extensions.json"); | |
OS.File.read(dataPath).then( | |
function onSuccess(arr) { | |
var data = new TextDecoder().decode(arr); | |
var json = JSON.parse(data); | |
json.addons.forEach(function(addon) { | |
if(!addon.active && addon.appDisabled) { | |
addon.appDisabled = false; | |
addon.active = !addon.userDisabled; | |
} | |
}); | |
var str = JSON.stringify(json); | |
arr = textEncoder.encode(str); | |
OS.File.writeAtomic(dataPath, arr, { backupTo: dataPath + bak }) | |
.then(null, Components.utils.reportError); | |
}, | |
Components.utils.reportError | |
).then(null, Components.utils.reportError); | |
// Flush cache (will be generated automatically) | |
var cachePath = OS.Path.join(OS.Constants.Path.profileDir, "extensions.ini"); | |
OS.File.move(cachePath, cachePath + bak); | |
// Restart | |
(function quitWithFlags(flags) { | |
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"] | |
.createInstance(Components.interfaces.nsISupportsPRBool); | |
var quitType = flags & Components.interfaces.nsIAppStartup.eRestart ? "restart" : null; | |
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", quitType); | |
if(cancelQuit.data) | |
return false; // somebody canceled our quit request | |
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"] | |
.getService(Components.interfaces.nsIAppStartup); | |
appStartup.quit(flags); | |
return true; | |
})( | |
Components.interfaces.nsIAppStartup.eAttemptQuit | |
| Components.interfaces.nsIAppStartup.eRestart | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment