Permalink
Browse files

Fix for YouTube

  • Loading branch information...
1 parent 0098569 commit e3939cba6efcceba2841c7e7f992a7f2cdf824c7 @rahulkapoor90 committed Feb 4, 2017
Showing with 10 additions and 6 deletions.
  1. +1 −1 manifest.json
  2. +9 −5 youtube.js
View
@@ -1,6 +1,6 @@
{
"name": "This is Clickbait",
- "version": "0.0.5",
+ "version": "0.0.7",
"author": "Rahul Kapoor",
"manifest_version": 2,
"description": "Shows whether the article is clickbait or not on Facebook & YouTube",
View
@@ -8,9 +8,9 @@ _gaq.push(['_trackPageview']);
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
-const youtube_clickbait = function() {
+const youtube_clickbait = function(node) {
- const images = [...document.getElementsByClassName('watch-title')];
+ const images = [...node.getElementsByClassName('watch-title')];
images.forEach(function(el) {
var link = el.innerHTML;
@@ -44,12 +44,16 @@ var request = new XMLHttpRequest();
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
- youtube_clickbait();
+ mutation.addedNodes.forEach(function(node) {
+ if (node.nodeType === 1) { // ELEMENT_NODE
+ youtube_clickbait(node);
+ }
+ });
});
});
-const config = { attributes: true, childList: true, characterData: false }
+const config = { attributes: false, childList: true, characterData: false, subtree: true }
observer.observe(document.body, config);
-youtube_clickbait();
+youtube_clickbait(document.body);

0 comments on commit e3939cb

Please sign in to comment.