Last active
September 14, 2016 15:39
-
-
Save ElfhirDev/1e36e0ea995814a0e6053b203a4d0c10 to your computer and use it in GitHub Desktop.
Remove suggested video because not relevant most of the time : based on previously seen video, videos in my subscribs but already seen ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name yt-anti-suggested-video | |
// @namespace yt-anti | |
// @description remove suggested video because not relevant | |
// @include https://www.youtube.com/* | |
// @version 1.5 | |
// @grant none | |
// @require https://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.6/zepto.min.js | |
// ==/UserScript== | |
$(document).ready(function () { | |
var lang = $("html").attr("lang"); | |
var regex = /Recommandée pour vous/; | |
switch(lang) { | |
case "fr": | |
regex = /Recommandée pour vous/; | |
break; | |
case "en": | |
regex = /Recommended for you/ | |
break; | |
case "es": | |
regex = /Recomendado para ti/ | |
break; | |
case "de": | |
regex = /Empfohlenes Video/ | |
break; | |
case "it": | |
regex = /Consigliato per te/ | |
break; | |
case "pt": //Brasil | |
regex = /Recomendado/ | |
break; | |
case "vi": | |
regex = /Được đề xuất cho bạn/ | |
break; | |
default: | |
regex = /Recommandée pour vous/; | |
break; | |
} | |
var removeSuggestedVideo = function() { | |
$(".video-list-item").each(function(i) { | |
var suggestedText = $(this).children().find(".view-count").html(); | |
if (!$.isEmptyObject(suggestedText)) { | |
if (suggestedText.match(regex)) { | |
$(this).remove(); | |
} | |
} | |
}); | |
}; | |
var time1 = setTimeout(function() { | |
removeSuggestedVideo(); | |
}, 1000); | |
var time2 = setInterval(function() { | |
removeSuggestedVideo(); | |
}, 60000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
version 1 : Array of string to detect.
version 1.1 : Update to a RegEx detection.
version 1.2 : Add isEmptyObject dectection when the .view-count element has other html in it.
version 1.3 : Add setTimeout in order to deal with lazy adding of video suggested.
version 1.4 : Add some other languages support (mainly european).
version 1.5 : Add a setInterval of 1 minute if the previous removal failed, or if some AJAX would add videos.