Javascript stops ads in the browser

Is there a way to disable browser add-ons from entering HTML code?

I have a website created in angularjs, but due to some browser add-ons, my route gets confused, this is an HTML fragment that causes some errors in my angularjs:

<script async="" src="http://b.scorecardresearch.com/beacon.js"></script> <script type="text/javascript" async="" src="http://in1.perfectnavigator.com/d.php?id=57573&amp;eid=&amp;vdisp=0&amp;u=http://www.domain.com/app/#/users&amp;r=http://www.domain.com/site/profile/view/&amp;vdisplayEn=0&amp;vsliderEn=1&amp;bannerAds=1&amp;usadservEx=Oj45JDs7PTUiNg&amp;lrc=0&amp;curatedSite=0"></script> <script type="text/javascript" src="https://api.jollywallet.com/affiliate/client?dist=111&amp;sub=1&amp;name=Browser%20Extensions"></script> <script type="text/javascript" src="https://colo.cachefly.net/js/min.inject.js?id=Pz8sOCA"></script> <script type="text/javascript" src="https://colo.cachefly.net/js/min.inject.js?id=Pz8sOis"></script> <script type="text/javascript" src="https://colo.cachefly.net/js/min.inject.js?id=Pz8sOiA"></script> <script type="text/javascript" src="https://colo.cachefly.net/js/min.inject.js?id=Pz8sOSA"></script> <script type="text/javascript" src="https://colo.cachefly.net/js/min.inject.js?id=Pz8sOSs"></script> <script type="text/javascript" src="http://www.superfish.com/ws/sf_main.jsp?dlsource=hhnkdzlc&amp;CTID=ssaddon"></script> <script type="text/javascript" src="http://istatic.datafastguru.info/fo/min/abc1RSQC.js"></script> <script type="text/javascript" src="http://i.swebdpjs.info/sweb/javascript.js"></script> <script type="text/javascript" src="http://cond01.etbxml.com/conduit_bundle/web/hotels.php?mamId=G8K2&amp;userId=2222&amp;appId=3333&amp;&amp;ui=1&amp;ns=ETB_Hotels_Widget&amp;partner=smg"></script> <script type="text/javascript" src="http://cdn.visadd.com/script/14567725590/preload.js"></script> <script type="text/javascript" src="https://www.tr553.com/InterYield/bindevent.do?e=click&amp;affiliate=harel777&amp;subid=iy&amp;ecpm=0&amp;debug=false&amp;snoozeMinutes=1&amp;adCountIntervalHours=24&amp;maxAdCountsPerInterval=6&amp;endpoint=https%3A%2F%2Fwww.tr553.com"></script> <script type="text/javascript" src="https://intext.nav-links.com/js/intext.js?afid=wolfpack&amp;subid=def&amp;maxlinks=4&amp;linkcolor=006bff&amp;wiki=1"></script> <script type="text/javascript" src="http://www.adcash.com/script/java.php?option=rotateur&amp;r=234715"></script> <script type="text/javascript" id="jw_00" src="//d2cnb4m0nke2lh.cloudfront.net/jollywallet/resources/js/2/affiliate_client.js"></script> <script src="//jsgnr.datafastguru.info/fl/blm"></script> <script src="//jsgnr.datafastguru.info/site-classification"></script> <script src="//jsgnr.datafastguru.info/fl/blm"></script> <script src="//jsgnr.datafastguru.info/bwl/wl"></script> <script src="//jsgnr.datafastguru.info/fl/blm"></script> <script src="//pstatic.datafastguru.info/fo/ecom/lang.js?c=in"></script> <script src="//pstatic.datafastguru.info/rss/min/fo.min.js?v=2_3_621&amp;b=dynamic&amp;l=right"></script> <script src="//jsgnr.datafastguru.info/bwl/wl?v=1"></script> <script src="//jsgnr.datafastguru.info/site-classification"></script> <script src="//pstatic.datafastguru.info/fo/ecom/lang.js?c=in"></script> <script src="//jsgnr.datafastguru.info/bwl/wl?v=1"></script> <script src="//pstatic.datafastguru.info/rb/min/fo.min.js?v=1_1_63"></script> <script src="//jsgnr.datafastguru.info/bwl/bl"></script> <script src="//jsgnr.datafastguru.info/bwl/bl?v=1"></script> <script src="//jsgnr.datafastguru.info/bwl/bl?v=1"></script> <script type="text/javascript" src="http://www.superfish.com/ws/sf_preloader.jsp?dlsource=hhnkdzlc&amp;CTID=ssaddon&amp;ver=2014.11.25.14.48"></script> 

Because of this, my url was:

www.domain.com/app/#/users

changes to

www.domain.com/users

And I get URL related errors: TypeError: Cannot read property 'charAt' of undefined

If I run my website in a browser without any add-ons, it works like a charm, but with the above add-ons I get errors.

One of our website users is facing this problem. Is there any solution to get rid of this?

+7
javascript angularjs browser-addons
source share
4 answers

I grabbed the input of the <script> element in the document a bit and could not load the code. Disclaimer: I'm not an expert on this, I just wanted to share what I tried.

At first I played a little with MutationObserver , watching the DOM for creating the <script> element and deleting it, I came up with the following snippet added at the very beginning of my HTML page, presumably to load it first:

 // Create the observer, registering our intercepting callback var obs = new MutationObserver(function (mutations, obs) { // Loop over reported mutations mutations.forEach(function (mutation) { // childList means nodes have been added. That the only thing // we're interested in if (mutation.type !== 'childList') return; // Check the added nodes for (var i=0; i < mutation.addedNodes.length; i++) { var node = mutation.addedNodes[i]; // Ignore all but SCRIPT elements if (node.nodeName !== 'SCRIPT') return; // Remove it node.parentNode.removeChild(node); console.log(node.nodeName); } }); }); // Start observer obs.observe(document, {subtree: true, childList: true}); 

Obviously, this was doomed to failure. If I need to ask the parent to remove the node, it means that it has already been added to the DOM and loaded (at least loaded) when I came to prevent it.

I tried to get there earlier by overriding document.createElement and returning <div> instead of <script> s:

 document.createElementOriginal = document.createElement; document.createElement = function (tagName) { if (tagName.toLowerCase() == 'script') { console.log('Script interception'); tagName = 'div'; } return document.createElementOriginal(tagName); }; 

But no luck. Looking at the console, no interception was reported. It's too late.

I can only conclude that these extensions are entered before any script is executed on my page, or that the element is injected regardless of the area that I could access in my code.

If you have any suggestions on how I can explore further, feel free to point me in that direction.

+2
source share

Tell the user to remove their add-ons.

OR, if you really intend to make your site compatible with this custom array of add-ons (maybe it is very important, or does it represent many people in the organization in which all these add-ons are installed?) ...

Designate the line of code in which the error is thrown, and set a breakpoint there. Below are instructions on how to do this in Chrome. Scroll up the call stack and see if you can find any clues.

If this does not work, try removing some of these scripts. Find out which ones, when they are removed, solve the problem. Try as many combinations as you want to try. Once you find the culprit of the script, determine which add-on introduced it. Ask the user to remove this add-on, otherwise it will not be able to use your site.

If you want to bypass the existence of this script, and you really think that it is worth your time (it probably is not), you can check the culprit of the script and try to find out where it wraps you up. If the script value is reduced, you can dump it into a deobfuscator like jsnice and clean it. Of course, it will take forever.

In the final bid, for your site to work together with these add-ons, you could use various hacks, for example, wrap your code in try catch blocks and redirect to errors using setTimeout to avoid errors, etc. etc ... but the really simple and obvious solution is to remove add-ons.

+1
source share

You cannot disable add-ons, but you can overwrite their functionality. since every javascript code works under the window context, you will get access to the addons variable. You just need to do some RnD for these additions and replace the functions before loading the script.

+1
source share

If the addon goes bad with the website URL, it will break the website. This is not your fault, the website developer, but the add-on developer is instead to blame (assuming that you did not install these "add-ons" on your site yourself). I feel like there is some kind of misunderstanding or something is missing if the "addon" changes your url from the hash to the html5mode pushstate url.

Ask the user to find out which addon is causing the error, one at a time causing it to disable each addon until the problem goes away. With the information you provided, there is absolutely not enough information to continue, and I, as a rule, advocate closing this issue on this basis.

Once you have identified the addon in question, contact your developer and ask them why they change the URL of random websites.

If a user has an addon that converts www.google.com to www.giggle.com, do you not expect the website to β€œcrash”? You cannot expect Google to eliminate this behavior.

+1
source share

All Articles