0

So I basically want to create a mini adblocker for a wesite. I have the snippet below which I can run in chrome and have a certain add removed. Is there a way to make it run automatically when the page is loaded?

var element = document.querySelector("[referrerpolicy='unsafe-url']");
    element.parentNode.removeChild(element);
  • Use a [userscript](//en.wikipedia.org/wiki/Userscript). – Sebastian Simon Feb 15 '22 at 20:29
  • Have you tried to wrap it in `window.onload = () => {var element = document.querySelector("[referrerpolicy='unsafe-url']"); element.parentNode.removeChild(element);}` ? – Dimitri Kopriwa Feb 15 '22 at 20:30
  • 2
    There are many Google results for this question. [Automatically run JavaScript code upon loading a specific website](https://stackoverflow.com/questions/22707808/automatically-run-javascript-code-upon-loading-a-specific-website). As a new member, please check out [how to ask](https://stackoverflow.com/help/how-to-ask) including the searching section. – Andy Ray Feb 15 '22 at 20:32

0 Answers0