Creating an add-in to hide the <div> block in an HTML page

There is a webpage with something annoying that I would like to hide every time I visit it. I thought a good way to do this is to make an add-on for Firefox.

I had never done this before and came across a Firefox web browser. I'm not too sure where to go from here. I know this should be fairly easy to do. I believe that all I need to do is check if a block with a specific identifier is used on the website, and if so, remove / hide it from my view.

Is this the best way to do this? If not, what do you suggest? If so, can you give me any tips to help me accomplish this?

+5
source share
6 answers

That's right, I realized:

Using only the standalone Firefox add-on, use the following code:

exports.main = function() {

    var pageMod = require("page-mod");
        pageMod.PageMod({
        include: "*.ca",
        contentScriptWhen: 'end',
        contentScript: 'document.getElementById("DIVID").style.visibility="hidden";'
    });
};

Just replace DIVIDwith what you want.

Similarly, in Greasemonkey just add this to the script:

document.getElementById('DIVID').style.visibility='hidden';

The only reason I didn’t want to use Greasemonkey is that sharing it is not so easy. But its convenience cannot be beaten!

+8
source
  • Install the latest FF
  • Install the latest AdBlock Plus
  • Go to the site with the right mouse button on a specific element, and then Inspect the element (Q)
  • In the lower right corner there is a Hide button using the ABP (AdBlock Plus) button , click on it, then Add a rule to hide elements
+2

GreaseMonkey, firefox. script JavaScript, .

, -, , script , http://userscripts.org/ .

+1

HTML id . - , ( ) class. , " ".

    var promotedTweets = document.getElementsByClassName("promoted-tweet");
    for (k=0; k<promotedTweets.length; k++) {
     promotedTweets[k].parentNode.removeChild(promotedTweets[k]);
    }
+1

Won't Adblock Plus do the trick here? You can give him a rule to hide an element (based on a class attribute or identifier) ​​on any site, if I remember correctly.

0
source

I used the tool jpmand wrote sentences here. This is specifically for filtering specific tags divhere on StackOverflow - how you can pick one. The code and additional file xpiare in Github .

0
source

All Articles