Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Javascript not modifying Youtube web page

$
0
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


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>