Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| 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(node) { | |
| const images = [...node.getElementsByClassName('watch-title')]; | |
| images.forEach(function(el) { | |
| var link = el.innerHTML; | |
| 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 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(); | |
| }); | |
| }; | |
| const observer = new MutationObserver(function(mutations) { | |
| mutations.forEach(function(mutation) { | |
| mutation.addedNodes.forEach(function(node) { | |
| if (node.nodeType === 1) { // ELEMENT_NODE | |
| youtube_clickbait(node); | |
| } | |
| }); | |
| }); | |
| }); | |
| const config = { attributes: false, childList: true, characterData: false, subtree: true } | |
| observer.observe(document.body, config); | |
| youtube_clickbait(document.body); |