2

Some google ads start injecting JavaScript and poping ads all over the screen

How can I block these random scripts that are injected through google ads?

Yovav
  • 2,557
  • 2
  • 32
  • 53
  • Are you asking as a user or a developer? For users I think adBlock should suffice, as a developer I think you could write a function that is executed periodically and looks in the DOM for a specific id/class that belongs to the ad popup. If it is found, it destroys it. – andreini Jun 20 '17 at 12:39
  • As a developer, the problem is that I don't know which IDs to look for because the scripts are injected through the google ads and they are random... I'm looking for a way to block these injected scripts but not the google ads scripts... – Yovav Jun 20 '17 at 12:45

1 Answers1

0

This is not perfect, but it seems to be very effective in my case (all pages are SSL) and also prevent SSL mixed mode messages caused by google ads third party plugin scripts...

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests; object-src 'none'">

Content-Security-Policy is critical to prevent mixed content errors (too many errors can show a "connection not secure" by the browser and memory leaks) https://blog.cloudflare.com/fixing-the-mixed-content-problem-with-automatic-https-rewrites and How does Content Security Policy work?

Yovav
  • 2,557
  • 2
  • 32
  • 53