Created
February 27, 2020 22:16
-
-
Save cadadr/ba3eb6de942eba460fac330b8cdb24da to your computer and use it in GitHub Desktop.
Non-playlist links in YouTube playlists
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-non-playlist-links | |
// @version 1 | |
// @grant none | |
// @namespace youtube.com/playlist | |
// @include https://www.youtube.com/playlist* | |
// @include https://youtube.com/playlist* | |
// ==/UserScript== | |
document.querySelectorAll( | |
'a.yt-simple-endpoint.ytd-playlist-video-renderer' | |
).forEach(function (vid) { | |
let url = new URL(vid.href); | |
let id = url.searchParams.get('v'); | |
let title = vid.querySelector('span#video-title'); | |
let text = title.textContent; | |
let newurl = new URL(url.origin); | |
newurl.pathname = url.pathname; | |
newurl.searchParams.set('v', id); | |
let sup = document.createElement('sup'); | |
let a = document.createElement('a'); | |
a.href = newurl.toLocaleString(); | |
a.innerText = '[nopl]'; | |
a.title = 'Non-playlist link, direct link to video.'; | |
sup.appendChild(a); | |
title.appendChild(sup); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment