I want to disable a specific JS script from a specific website without disabling the javascript completely. Is there a way to do that ?
Way to disable a specific JS script from a specific website
browserjavascript
Related Solutions
The (dead link) Anti-Disabler script on diveintogreasemonkey.org works if you replace document.
with document.wrappedJSObject.
Link appears to be dead now, here's a wayback link: http://web.archive.org/web/20110830050224/http://diveintogreasemonkey.org/download/antidisabler.user.js
and here's the script:
// Anti-Disabler
// version 0.5 BETA!
// 2005-06-28
// Copyright (c) 2005, Mark Pilgrim
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Anti-Disabler", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Anti-Disabler
// @namespace http://diveintomark.org/projects/greasemonkey/
// @description restore context menus on sites that try to disable them
// @include *
// @exclude http://mail.google.com/*
// @exclude https://mail.google.com/*
// ==/UserScript==
(function() {
var e, i, all;
document.onmouseup = null;
document.onmousedown = null;
document.oncontextmenu = null;
all = document.getElementsByTagName("*");
for (i = 0; i < all.length; i += 1) {
e = all[i];
e.onmouseup = null;
e.onmousedown = null;
e.oncontextmenu = null;
}
})();
//
// ChangeLog
// 2005-06-28 - 0.5 - MAP - updated GMail URL
// 2005-04-21 - 0.4 - MAP - linted
// 2005-04-21 - 0.3 - MAP - exclude GMail
// 2005-04-18 - 0.2 - MAP - tidy code
// 2005-04-01 - 0.1 - MAP - initial release
//
You can use the Greasemonkey add-on to rewrite the alert
function:
// ==UserScript==
// @name Catch JS Alert
// @namespace http://igalvez.net
// @include http://*
// @version 1
// @grant none
// @run-at document-start
// ==/UserScript==
window.alert = function(message) {
if(message == 'Adblock detected, please consider disabling it') {
console.log(message);
} else {
confirm(message);
}
}
The way this works is as follows:
If the alert box's message matches "Adblock detected, please consider disabling it", then discard it to the JS console (it will not be displayed). Otherwise, display the alert box as a confirm
box.
Best Answer
(Reference: http://noscript.net/faq#qa8_10)
After installing NoScript, open its option (by opening context menu on the small icon on the status bar/add-on bar, or through Addons Manager)
Go to Advanced tab. In that page, go to ABE tab. Under Rulesets, click on USER. Here is an example ruleset, put it in the textbox on the right:
I'm not sure how URL matching works, whether it uses regexp or not. Some examples on the FAQ does show regexp usage, but my example above seems to also match
ads.js?foobarbaz
.