Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Script for showing only watched videos on YouTube - more info in here: https://webapps.stackexchange.com/a/112602/173146
- //function to edit url query strings
- function updateQueryStringParameter(uri, key, value) {
- var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
- var separator = uri.indexOf('?') !== -1 ? "&" : "?";
- if (uri.match(re)) {
- return uri.replace(re, '$1' + key + "=" + value + '$2');
- }
- else {
- return uri + separator + key + "=" + value;
- }
- }
- function deleteMore() {
- //search through all videos in playlist
- var elements = document.getElementsByClassName("pl-video yt-uix-tile");
- for(i=elements.length-1;i>=0;i--) {
- //check if there's a progress bar in the video (if it has you have watched it)
- children = elements[i].getElementsByClassName("resume-playback-progress-bar");
- if (children.length>0) {
- //delete it!
- elements[i].remove();
- }
- }
- if(document.querySelector('.load-more-button') != null){
- //scroll down
- window.scrollTo(0,document.body.scrollHeight);
- //click the load more button
- document.querySelector('.load-more-button').click();
- //redo it again
- setTimeout(function(){deleteMore()}, 500);
- } else {
- //in case there's no more load more button (looped through all videos)
- //change all links to remove the annoying playlist links
- var links = document.getElementsByTagName("A");
- for(i=links.length-1;i>=0;i--) {
- url = links[i].getAttribute('href');
- if (url!=null) {
- url = updateQueryStringParameter(url,'list','');
- links[i].setAttribute('href',url);
- }
- }
- console.log("... IS DONE! *metal riffs*");
- }
- }
- deleteMore();
Add Comment
Please, Sign In to add comment