Skip to content

Instantly share code, notes, and snippets.

@cadadr

cadadr/nopl.js

Created Feb 27, 2020
Embed
What would you like to do?
Non-playlist links in YouTube playlists
// ==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
You can’t perform that action at this time.