Permalink
Browse files

Bug fixes

1 parent 679da29 commit ea9e70f5f9f702f8b6dee51ddd2d5eb89e06638f @rahulkapoor90 committed Feb 1, 2017
Showing with 69 additions and 2 deletions.
  1. BIN This is Clickbait.zip
  2. BIN logo32.png
  3. BIN logo64.png
  4. +10 โˆ’2 manifest.json
  5. +59 โˆ’0 youtube.js
View
Binary file not shown.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -1,9 +1,9 @@
{
"name": "This is Clickbait",
- "version": "0.0.1",
+ "version": "0.0.3",
"author": "Rahul Kapoor",
"manifest_version": 2,
- "description": "Shows whether the article title is clickbait or not on Facebook",
+ "description": "Shows whether the article is clickbait or not on Facebook & YouTube",
"permissions": [
"http://www.facebook.com/*", "https://www.facebook.com/*","https://clickbait-detector.herokuapp.com/*"
],
@@ -19,12 +19,20 @@
"16": "logo16.png",
"48": "logo48.png"
},
+ "content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
+ "homepage_url": "https://github.com/rahulkapoor90/This-is-Clickbait",
"content_scripts": [
{
"matches": ["http://www.facebook.com/*", "https://www.facebook.com/*"],
"js" : [ "facebook.js"],
"run_at" : "document_idle",
"all_frames" : false
+ },
+ {
+ "matches": ["http://www.youtube.com/*", "https://www.youtube.com/*"],
+ "js" : [ "youtube.js"],
+ "run_at" : "document_idle",
+ "all_frames" : false
}
]
}
View
@@ -0,0 +1,59 @@
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-73159092-1']);
+_gaq.push(['_trackPageview']);
+
+(function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = 'https://ssl.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+
+const youtube_clickbait = function() {
+
+ const images = [...document.getElementsByClassName('watch-title')];
+
+ images.forEach(function(el) {
+ var link = el.innerHTML;
+ console.log(link);
+var request = new XMLHttpRequest();
+ request.onreadystatechange = function() {
+ if (request.readyState === 4) {
+ if (request.status === 200) {
+ var data = JSON.parse(request.responseText);
+ var clickbait = data.clickbaitiness;
+ if(clickbait<60){
+ let html = "<ul style='position:absolute;top:30px;right:10px;padding:5px;font-size:12px;line-height:1.8;background-color:#2ecc71;color:#fff;border-radius:5px'>๐Ÿ‘ Not a Clickbait</ul>";
+ el.insertAdjacentHTML('afterend', html);
+ }
+ else if(clickbait > 90){
+ let html = "<ul style='position:absolute;top:30px;right:10px;padding:5px;font-size:12px;line-height:1.8;background-color:#F27935;color:#fff;border-radius:5px'>๐Ÿ’ This is Clickbait</ul>";
+ el.insertAdjacentHTML('afterend', html);
+ }
+ else {
+ let html = "<ul style='position:absolute;top:30px;right:10px;padding:5px;font-size:12px;line-height:1.8;background-color:#e67e22;color:#fff;border-radius:5px'>๐Ÿ‘ป "+clickbait+"% clickbait</ul>";
+ el.insertAdjacentHTML('afterend', html);
+ }
+ }
+ }
+ };
+
+ request.open("GET", "https://clickbait-detector.herokuapp.com/detect?headline="+link , true);
+ request.send();
+ });
+
+};
+
+
+youtube_clickbait();
+
+const observer = new MutationObserver(function(mutations) {
+ mutations.forEach(function(mutation) {
+ youtube_clickbait();
+ });
+});
+
+const config = { attributes: true, childList: true, characterData: false }
+
+observer.observe(document.body, config);
+
+youtube_clickbait();

0 comments on commit ea9e70f

Please sign in to comment.