Quote
Trisha
So it is impossible to allow JS only on certain websites?
Yes, it is possible.
In past, i've added a few lines to km and it works fine. I prefer to block javascript just on several websites, but same code will do the job for you.
Go to about:config and check if there exist pref 'permissions.default.script'. If not, you need to add a new INT pref, then set the value to 2.
Global javascript must be enabled.
Paste this code into the error console and make some tests:
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://gre/modules/Services.jsm');
const TEST = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == 'content-document-global-created') {
var ALLOW_ACTION = 1, DENY_ACTION = 2, permission = Services.perms.testPermission(aSubject.document.documentURIObject, 'script'),
doc = aSubject.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell);
if ((Services.prefs.getIntPref('permissions.default.script') == DENY_ACTION && permission != ALLOW_ACTION) ||
!Services.prefs.getBoolPref('javascript.enabled') || permission == DENY_ACTION)
doc.allowJavascript = false;
else
doc.allowJavascript = true;
}
},
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver, Components.interfaces.nsISupportsWeakReference])
};
Services.obs.addObserver(TEST, 'content-document-global-created', true);
If you need something like this, you or someone can put this code in an addon.
Best regards to all