Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use stylish userscript or javascript to remove this html element? [closed]

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

<div class=main>
    <h2>Title</h2>
    <div class=stuff>
    //bunch of other stuff
    </div>
    <a href="ad.com">ad</a>

</div>
like image 749
arboles Avatar asked Mar 31 '13 17:03

arboles


1 Answers

I have made a chrome extension for this purpose, named Js-Injector. It is available from github on https://github.com/shahverdy/JS-Injector. Unfortunately I can not deploy it on Chrome Web Store, because of US sanctions on my country. There are some samples in extension for this purpose, you can easily work with it.

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

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

EDIT: There are some other extensions like Tampermonkey available. But there are some important issues that should be considered at the time of choosing proper extension:

  • Js-Injector is really easy to use
  • Js-Injector has Import/Export feature available for your scripts.
  • There are some predefined samples, so you can select to use them without writing any codes.
  • Js-Injector is really light.
  • Js-Injector runs scripts for each website on its own scope, so it doesn't consume that much RAM/CPU
like image 82
Mostafa Shahverdy Avatar answered Oct 14 '22 10:10

Mostafa Shahverdy