Last active
December 10, 2015 16:28
-
-
Save justinwoo/4461136 to your computer and use it in GitHub Desktop.
Filters the Youtube "What to watch" page using discriminants set by the user, namely the age by days of the videos and whether or not they are recommended items. lemme know if there are bugs guys, it's 6am and i started this at 4:30am. Userscript page: http://userscripts.org/scripts/show/155774 edit: maybe i should replace inner html with outer …
This file contains 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 Youtube Feed Filterer | |
// @namespace http://www.github.com/kimagure | |
// @description Filters the Youtube "What to watch" page using discriminants set by the user, namely the age by days of the videos and whether or not they are recommended items. | |
// @include http://www.youtube.com/* | |
// @include http://www.youtube.com/feed/what_to_watch | |
// @exclude http://www.youtube.com/watch?* | |
// @exclude http://www.youtube.com/user/* | |
// @exclude http://www.youtube.com/feed/* | |
// @version dev | |
// ==/UserScript== | |
//how old of crap you even want to see | |
var ageThreshold = parseInt(prompt('How many days are we looking back?', '2'), 10); | |
var recHide = confirm("Block recommendations?\nOkay = Yes; Cancel = No") | |
function removals(){ | |
var elements = document.getElementsByClassName("feed-item-container "); | |
for (var i = 0; i < elements.length; i++) { | |
var inner = elements[i].innerHTML; | |
if (inner.search("<a href=\"/feed/recommended\">Recommended</a> for you") != -1 && recHide) { | |
elements[i].innerHTML = "" //hide recommendations it | |
} | |
var daysfind = inner.search("days ago"); | |
if (daysfind != -1) { | |
if (inner[daysfind - 2] > ageThreshold) | |
elements[i].innerHTML = "" //hide old stuff | |
} | |
if (inner.search("week ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff it's like 6 am im not gonna try to make thsi pretty | |
} | |
if (inner.search("weeks ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff it's like 6 am im not gonna try to make thsi pretty | |
} | |
if (inner.search("month ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
if (inner.search("months ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
if (inner.search("year ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
if (inner.search("years ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
} | |
} | |
removals(); | |
//listen for more crap being loaded in by feed container | |
feedcontainer = document.getElementsByClassName("feed-container")[0]; | |
if (feedcontainer.addEventListener) { | |
feedcontainer.addEventListener('DOMSubtreeModified', OnSubtreeModified, false); | |
} | |
function OnSubtreeModified () { | |
removals(); | |
} |
This file contains 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 Youtube Feed Filterer | |
// @namespace http://www.github.com/kimagure | |
// @description Filters the Youtube "What to watch" page using discriminants set by the user, namely the age by days of the videos and whether or not they are recommended items. | |
// @include http://www.youtube.com/* | |
// @include http://www.youtube.com/feed/what_to_watch | |
// @exclude http://www.youtube.com/watch?* | |
// @exclude http://www.youtube.com/user/* | |
// @exclude http://www.youtube.com/feed/* | |
// @version dev | |
// ==/UserScript== | |
//how old of crap you even want to see | |
// var ageThreshold = parseInt(prompt('How many days are we looking back?', '2'), 10); | |
// var recHide = confirm("Block recommendations?\nOkay = Yes; Cancel = No") | |
//just hard set values in this version to save time and keystrokes | |
ageThreshold = 2; | |
recHide = 'True'; | |
function removals(){ | |
var elements = document.getElementsByClassName("feed-item-container "); | |
for (var i = 0; i < elements.length; i++) { | |
var inner = elements[i].innerHTML; | |
if (inner.search("<a href=\"/feed/recommended\">Recommended</a> for you") != -1 && recHide) { | |
elements[i].innerHTML = "" //hide recommendations it | |
} | |
var daysfind = inner.search("days ago"); | |
if (daysfind != -1) { | |
if (inner[daysfind - 2] > ageThreshold) | |
elements[i].innerHTML = "" //hide old stuff | |
} | |
if (inner.search("week ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff it's like 6 am im not gonna try to make thsi pretty | |
} | |
if (inner.search("weeks ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff it's like 6 am im not gonna try to make thsi pretty | |
} | |
if (inner.search("month ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
if (inner.search("months ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
if (inner.search("year ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
if (inner.search("years ago") != -1) { | |
elements[i].innerHTML = "" //hide ancient stuff | |
} | |
} | |
} | |
removals(); | |
//listen for more crap being loaded in by feed container | |
feedcontainer = document.getElementsByClassName("feed-container")[0]; | |
if (feedcontainer.addEventListener) { | |
feedcontainer.addEventListener('DOMSubtreeModified', OnSubtreeModified, false); | |
} | |
function OnSubtreeModified () { | |
removals(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment