How to use stylish usercript or javascript to remove this html element?

on the website I visit, I want to remove the advertising link from the page by writing a script. how would I remove the <a href-"ad">ad</a> page element? I guess the best way is to use javascript and use the chrome tampermonkey extension to run the script. otherwise using a stylish and css script.

 <div class=main> <h2>Title</h2> <div class=stuff> //bunch of other stuff </div> <a href="ad.com">ad</a> </div> 
+7
source share
1 answer

I made a chrome extension for this purpose called Js-Injector . It is available from github at https://github.com/shahverdy/JS-Injector . Unfortunately, I cannot deploy it to the Chrome Web Store due to U.S. sanctions in my country. There are several examples of extensions for this purpose that you can easily work with.

In Js-Injector, you can add the following code for your site:

 $(function(){ $("a[href='ad.com']").remove(); }) 

EDIT . There are other extensions, such as Tampermonkey. But there are some important issues to consider when choosing the right extension:

  • Js-Injector is really easy to use.
  • Js-Injector has an import / export feature available for your scripts.
  • There are some predefined examples, so you can choose to use them without writing any codes.
  • Js-Injector is really bright.
  • Js-Injector runs scripts for each website in its own area, so it does not consume as much RAM / CPU
+10
source

All Articles