Skip to content

Instantly share code, notes, and snippets.

@badp
Created April 29, 2012 18:26
Show Gist options
  • Save badp/2552456 to your computer and use it in GitHub Desktop.
Save badp/2552456 to your computer and use it in GitHub Desktop.
Enough with people reuploading others' stuff on their own Youtube channels.
badChannels = ["gamehelper", "gamerspawn", "machinima", "vaivecorporation", "loquendoitalia", "patron500", "jon3pnt0"]
$(jQuery.grep($(".video-list-item, .result-item, .result-item-main-content, .sidebar-ads, .yt-tile-default"),
function(item, number){
//filter regular videos
username = $(item).find(".yt-user-name").text().toLowerCase();
console.debug(username)
if(badChannels.indexOf(username) != -1) return true;
//perhaps it's an ad.
username = $(item).find(".ads-by a").text().toLowerCase();
console.debug(username)
if(badChannels.indexOf(username) != -1) return true;
return false;
})).css('opacity', 0.1);
//Why not hide it entirely? For example, on your homepage these things come with an handy ",
//perhaps it's a related channel ad thing
$(jQuery.grep($(".related-channel"),
function(item, number){
//filter regular videos
username = $(item).find(".title").text().toLowerCase();
if(badChannels.indexOf(username) != -1) return true;
return false;
})).css('opacity', 0.1);
//perhaps it's one of the videos featured at the end with the HTML5 player. Unfortunately I will need to poll for these ones apparently. These are much more in your face, though, so let's be harsher with these ones.
setInterval( function(){
$(jQuery.grep($(".videowall-still"),
function(item, number){
//filter regular videos
username = $(item).find(".videowall-info-author").text().toLowerCase();
if(badChannels.indexOf(username) != -1) return true;
return false;
})).remove()
}, 1000);
//perhaps we are on this guy's page, even. Let's do something about it.
var username;
try {
username = document.getElementById("watch-userbanner").title.toLowerCase();
} catch(e) { //ugh, what's next is totally unreliable
username = $("#watch-headline-user-info .yt-uix-button-content")[0].innerText.toLowerCase();
}
if(badChannels.indexOf(username) != -1){
if(confirm("You flagged this channel, " + username + ", as bad. Search another such video instead?")){
videoTitle = document.getElementById("eow-title").innerText
window.location = "http://www.youtube.com/results?search_query=" + escape(videoTitle)
}
}
@thomas-mcdonald
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment