Last active
August 29, 2015 14:04
-
-
Save k98kurz/3ba6ac71a32bd36d21c3 to your computer and use it in GitHub Desktop.
This removes the "uploads" playlist from video links on channels
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 No More YouTube Uploads Playlist | |
// @namespace https://gist.github.com/k98kurz | |
// @updateUrl https://gist.githubusercontent.com/k98kurz/3ba6ac71a32bd36d21c3/raw/ | |
// @version 2.1 | |
// @description This removes the "uploads" playlist from video links on channels | |
// @match https://www.youtube.com/user/*/videos | |
// @match http://www.youtube.com/user/*/videos | |
// @match https://www.youtube.com/channel/*/videos | |
// @match http://www.youtube.com/channel/*/videos | |
// @match https://www.youtube.com/user/*/videos?*view=0* | |
// @match http://www.youtube.com/user/*/videos?*view=0* | |
// @match https://www.youtube.com/channel/*/videos?*view=0* | |
// @match http://www.youtube.com/channel/*/videos?*view=0* | |
// @copyright 2014+, me | |
// ==/UserScript== | |
(function(w) { | |
var t; | |
// sterilization function | |
w.sterilizeVideoLinks = function () { | |
var i, elements = document.querySelectorAll ("a.yt-uix-tile-link, a.ux-thumb-wrap"); | |
for (i=0;i<elements.length;++i) { | |
if (elements[i].href.split("&").length>1) | |
elements[i].setAttribute("data-old-link", elements[i].href); | |
elements[i].href = elements[i].href.split("&")[0]; | |
} | |
}; | |
// desterilization function | |
w.desterilizeVideoLinks = function () { | |
var i, elements = document.querySelectorAll ("a.yt-uix-tile-link, a.ux-thumb-wrap"); | |
for (i=0;i<elements.length;++i) | |
elements[i].href = (elements[i].getAttribute("data-old-link") ? elements[i].getAttribute("data-old-link") : elements[i].href); | |
}; | |
// automate when load-more-button is clicked | |
t = document.querySelector("button.load-more-button"); | |
if (t&&typeof t.addEventListener=='function') { | |
t.addEventListener ("click", function(e) { | |
if (localStorage.autoSterilizeLinks=="true") | |
setTimeout(w.sterilizeVideoLinks, 1000); | |
}); | |
} | |
t = (new DOMParser()).parseFromString('<li><input type="checkbox" id="sanitize-links-toggle" />' + | |
'<a style="color:#000;font-weight:bold" onclick="return false;">Sanitize Links</a></li>', | |
'text/html').firstChild.childNodes[1].firstChild; | |
t.firstChild.addEventListener("click", function(){ | |
if (localStorage.autoSterilizeLinks=="false") { | |
localStorage.autoSterilizeLinks = "true"; | |
sterilizeVideoLinks(); | |
} else { | |
localStorage.autoSterilizeLinks = "false"; | |
desterilizeVideoLinks(); | |
} | |
}); | |
if (localStorage.autoSterilizeLinks=="true") { | |
t.firstChild.checked = true; | |
document.addEventListener("DOMContentLoaded", w.sterilizeVideoLinks); | |
} | |
t.childNodes[1].addEventListener("click", w.sterilizeVideoLinks); | |
document.querySelector("ul.appbar-nav-menu").appendChild(t); | |
// add desterilization link | |
t = (new DOMParser()).parseFromString('<li><a style="color:#ccc;font-weight:bold" onclick="return false;">Desanitize Links</a></li>', | |
'text/html').firstChild.childNodes[1].firstChild; | |
t.childNodes[0].addEventListener("click", w.desterilizeVideoLinks); | |
document.querySelector("ul.appbar-nav-menu").appendChild(t); | |
})(unsafeWindow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment