0

I'm learning how to create firefox extensions. I just started developing one to delete youtube comments.

manifest json:

{
        "name": "Comment-Blocker",
        "version": "1.1",
        "manifest_version": 2,

        "description": "Blocks comments on an youtube video by specified user",

        "content_script": [
                {
                        "matches": ["*://*.youtube.com/watch?v=*"],
                        "js": ["/commentBlocker.js"]
                }
        ],

        "browser_action": {
                "browser_style": true,
                "default_icon": {
                        "48": "/icon.png"
                },
                "default_title": "Comment Deleter",
                "default_popup": "/popup.html"
        },

        "permissions": [
                "*://www.youtube.com/watch?v=*",
                "storage",
                "activeTab"
        ]

}

commentBlocker.js:

var comments = document.getElementById("contents").getElementsByClassName("style-scope ytd-item-section-renderer");

for(i = 0; i < comments.length; i++) // length does not include reply chains
{
        var name = comments[i].querySelector('#author-text');
        if(name.href == 'https://www.youtube.com/channel/UC-CrrqEdTkOP0BD6_KQ64Uw')
        {
                comments[i].hidden = true;
        }
}

Problem is, when I load the temporary add-on the top comment is not dissapearing. When I write the instructions in console it works. What am I doing wrong?

youtube video used for testing: https://www.youtube.com/watch?v=Jk71bPz5VLo

USER149372
  • 83
  • 2
  • 6
  • This maybe sounds like a dumb question but is the code in your `commentBlocker.js` really running? If so it could be that on the time it runs there is no comment loaded because the commentsection only gets loaded if you scroll down to it. So maybe thats the problem? – Jonas Weinhardt Sep 30 '21 at 06:51

0 Answers0