Discussions » Development

How to disable specific java script

§
Posted: 2018-08-10
Edited: 2018-08-10

How to disable specific java script

Some site (html) contains the following code:

<script>
    document.addEventListener('DOMContentLoaded', function(){
        $('.answer-text > div:first').attr('class', 'defdecefcfeda');
        try {
            var script = document.createElement('script');
            script.src = '###LINK TO SOME *.JS SCRIPT###';
            script.onerror = function() {
                adbd('defdecefcfeda', 'qqg', '###SOME UNDESIRABLE TEXT###');
            };
            script.onload = function () {
                adbd('defdecefcfeda', 'qqg', '###SOME UNDESIRABLE TEXT###');
                SomeFunc1.setOption('debug', false);
                SomeFunc1.setOption('baitClass', 'pub_300x250 propel-ad adfox rtb pub_300x250m dfp-slot__banner dfp-slot__placeholder dfp-slot__placeholder-text pub_teasers pud_ads pub_300x600 center_adsense advertorial-block hr-ads adboxbot pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links');
                SomeFunc1.onDetected(function () {
                    adbd('defdecefcfeda', 'qqg', '###SOME UNDESIRABLE TEXT###');
                });
                 SomeFunc1.onNotDetected(function () {
                 });
            };
            document.documentElement.appendChild(script);
        } catch (err) {}
    });
</script>  

I need to do only one thing among 3: 1) OR Disable (delete\replace) array of commands in a whole block "script" 2) OR Delete EventListener (not using deleteEventListener because it doesn't work here) 3) OR Forbid geting script from URL in line 6 (Not desirable solution, because it may has no effect)

(Attachment: File with code that given before but with spaces and tabs to better viewing)

§
Posted: 2018-10-01

maybe you can add the link of line 6 onto ublock Orign or Adblock or other blocker if you has some feature of the link address. ScriptManager inject the script after the DOMContentLoaded event, so it too late to block a script on the html dom if you use a script from scriptManager

§
Posted: 2019-03-29
Edited: 2020-07-03

for example, you can make the usage of this one prefs.js: userpref("capability.policy.policynames", "killfunction"); userpref("capability.policy.killfunction.open", "noAccess"); userpref("capability.policy.killfunction.XMLHttpRequest.open", "noAccess"); userpref("capability.policy.killfunction.XMLHttpRequest.send", "noAccess"); user_pref("capability.policy.killfunction.sites", http://evilsite.org);

Post reply

Sign in to post a reply.