Skip to content

Instantly share code, notes, and snippets.

@crgarridos
Created October 27, 2017 10:28
Show Gist options
  • Save crgarridos/c81160d60ed4e74d32b56ae4e35c5ba0 to your computer and use it in GitHub Desktop.
Save crgarridos/c81160d60ed4e74d32b56ae4e35c5ba0 to your computer and use it in GitHub Desktop.
Delete search history entries from youtube
//var inter = setInterval(function(){window.scrollTo(0,document.querySelector("ytd-app").scrollHeight); }, 15000)
function contains(target, tests){
var target = target.toLowerCase();
for(i in tests){
if(target.indexOf(tests[i].toLowerCase()) != -1){
return true;
}
}
return false;
}
function isHearstoneRelated(meta){
var bannedWords = ["hearthstone", "trump", "savjz", "feelink", "firebat", "atlas",
"brian kibler", "krigam", "kolento", "pavel", "wowhobbs", "hysteria",
"zeromana", "omnislash"];
for(key in meta){
if(typeof key !== "undefined" && contains(meta[key], bannedWords))
return true;
}
return false;
}
var entries2 = document.getElementsByTagName("ytd-video-renderer");
console.log(entries2)
for(i in entries2) {
if(parseInt(i) !== false){
console.log(i)
let entry = entries2[i];
console.log(entry)
try{
var rightBox = entry.children[0].children[1];
var titleBar = rightBox.children[0].children[0];
var meta = {
title: titleBar.children[0].children[1].title,
channel: rightBox.children[0].children[1].children[0].children[0].children[0].children[0].children[0].innerText,
description: rightBox.children[1].innerText
}
if(isHearstoneRelated(meta)){
var deleteButton = titleBar.children[1].children[0].children[0].children[0].children[0].children[0]
deleteButton.click()
}
} catch(ex){
console.error(ex);
//break;
}
}
}
console.log("Done !")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment