Everyday, I visit the Norwegian news site "www.vg.no" to catch up on the latest news. However, one day while browsing on my school computer with adblock installed, I noticed that the ads were removed but an ad wrapper appeared asking to turn off adblock. Being a student of information technology, I decided to develop a chrome extension to completely eliminate these ad wrappers.
After creating the extension and using a content_script that executed a script once the page loaded, which I named script.js
My script successfully removed the ad wrappers, but I encountered a new challenge. The div that wrapped around the ad wrapper changed its class name on every page load due to a script on the site that randomized it.
The randomization script looked complicated with various styles and elements being generated dynamically. I needed to find a way to target the div containing the ad even with the changing class names. Additionally, within the div, there was a paragraph <p class="t1">
that I attempted to remove, but it didn't work.
Any suggestions on how I could identify the class name of the div to delete it? Perhaps converting the entire script into a string and searching for the dummy variable may help. I also wondered if there's a way to create an uneditable function to prevent it from being overridden once the page fully loads.