How to disable a specific javascript function?

Everything about using Adblock Plus on Google Chrome
Post Reply
JD2
Posts: 7
Joined: Sat Aug 17, 2013 6:54 am

How to disable a specific javascript function?

Post by JD2 »

I have AdBlock Plus v1.5.4 for Chrome.

I would like to block the following javascript function that is contained in a webpage. I do not want to block the rest of the page. The javascript script is as follows:

<script type="text/javascript">

function TestPage() {
if ($('.myTestAd').height() == 0)
window.location = "http://<redacted>/adblock.php?link=<redacted>";
}

$(TestPage);

</script>

I assume that simply removing or blocking "$(TestPage);" on this page would prevent this script from being executed. However I don't know how to write the rule to block it as this is not a <div> element.

So, does anyone know how to write the rule to block this specific script?
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: How to disable a specific javascript function?

Post by mapx »

an inline script (in HTML) can not be blocked; you can block only an external script

you can write a userscript and use it directly in chrome (drag & drop it in the extensions page) or using some script manager (like greasemonkey for firefox or Tampermonkey for chrome)

see also
https://userscripts.org/
JD2
Posts: 7
Joined: Sat Aug 17, 2013 6:54 am

Re: How to disable a specific javascript function?

Post by JD2 »

Thanks for the info!

The script at https://userscripts.org/scripts/show/155840 along with the Tampermonkey extension for Chrome did the trick.
BoyBlueSky
Posts: 1
Joined: Sun Nov 17, 2019 8:16 pm

Re: How to disable a specific javascript function?

Post by BoyBlueSky »

The UserScripts.org site is down,
but there is a static mirror of the site.
So, the previously mentioned link:
https://userscripts.org/scripts/show/155840
can instead be found at:
https://userscripts-mirror.org/scripts/review/155840
^_^
Post Reply