Last active
March 9, 2022 20:58
-
-
Save Fraasi/488037a76a7f51d29e71a77d68e3d120 to your computer and use it in GitHub Desktop.
Tampermonkey script to change youtube playlist title link to playlist page instead of first item in playlist & prevent autoplays
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 playlist link fix & prevent autoplays | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2.0 | |
// @description Change playlist title link to playlist page instead of first item in playlist & prevent autoplays | |
// @author Fraasi | |
// @match https://www.youtube.com/* | |
// @run-at document-end | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let n = 0; //fixes playlist no button pause loop | |
function toggleAutoPlay() { | |
const button = document.getElementById('toggle'); | |
const video = document.querySelector('video'); | |
//console.log(button); | |
if (video) { | |
video.pause(); | |
} | |
if (button) { | |
handleClick(button); | |
} else if (n < 5) { | |
n++; | |
setTimeout(toggleAutoPlay, 1000); | |
} | |
} | |
function handleClick(button) { | |
if (button.getAttribute('aria-pressed') === 'true') { | |
button.click(); | |
} | |
} | |
toggleAutoPlay(); | |
function changePlaylistLinks() { | |
if (!window.location.href.includes('playlists')) { | |
return; | |
} | |
const playLists = document.querySelectorAll('a.yt-simple-endpoint.style-scope.ytd-grid-playlist-renderer'); | |
playLists.forEach( playlist => { | |
const listID = playlist.href.match(/[A-Za-z0-9_-]+$/)[0]; | |
playlist.href = `https://www.youtube.com/playlist?list=${listID}`; | |
playlist.addEventListener('click', e => e.stopPropagation()); | |
}); | |
} | |
window.addEventListener('yt-visibility-refresh', changePlaylistLinks); | |
})(); |
Weird, doesn't complain anything on my Vivaldi 5.0.2497.48 (Stable channel) (64-bit) & tampermonkey v4.14.
Anyhoo, this is an old & obsolete script nowdays as youtube has put a 'VIEW FULL PLAYLIST' link on every playlist and I haven't used this myself for quite some time.
If you want the 'prevent autoplay' feature, I'm sure you can find a better uptodate script somewhere else.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script not recognized as compatible with Tampermonkey version 4.13.6136. Mozilla Firefox 98.0 (64-bit).