Skip to content

Instantly share code, notes, and snippets.

@nkmathew
Last active December 13, 2021 18:30
Show Gist options
  • Save nkmathew/d73a319cdd32825cafde9aa5fc1ff22d to your computer and use it in GitHub Desktop.
Save nkmathew/d73a319cdd32825cafde9aa5fc1ff22d to your computer and use it in GitHub Desktop.
Tampermonkey script that adds a navigation button for getting to your watch later playlist easily
// ==UserScript==
// @name Youtube WatchLater Button
// @namespace http://nkmathew.net
// @version 0.2.0
// @description Adds a button for getting to your watch later playlist easily
// @icon http://youtube.com/favicon.ico
// @icon64 http://youtube.com/favicon.ico
// @author nkmathew
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var downloadButton;
var anchorText = document.createElement('span');
var button = document.createElement('a');
var buttonsContainer = document.createElement('span');
var userMasthead = document.getElementById('yt-masthead-user');
var youtubeUrl = encodeURIComponent(window.location);
var downloaders = {
savido : 'http://www.savido.net/download?url=',
keepvid : 'http://www.keepvid.com/?url=',
};
// Button text
anchorText.innerText = 'Watch Later';
anchorText.classList.add('yt-uix-button-content');
// Watch Later button node
button.href = '/playlist?list=WL';
button.style.fontWeight = 'bold';
button.style.height = '29px';
button.style.marginLeft = '5px';
button.classList.add('guide-watch-later-icon');
button.classList.add('no-icon-markup');
button.classList.add('play-all-icon-btn');
button.classList.add('playlist-play-all');
button.classList.add('spflink');
button.classList.add('watchlater-button');
button.classList.add('yt-uix-button');
button.classList.add('yt-uix-button-default');
button.classList.add('yt-uix-button-has-icon');
button.classList.add('yt-uix-button-playlist-action');
button.classList.add('yt-uix-button-size-default');
button.classList.add('yt-uix-sessionlink');
button.appendChild(anchorText);
// Download button
downloadButton = button.cloneNode(true);
downloadButton.href = downloaders.keepvid + youtubeUrl;
downloadButton.setAttribute('target', '_blank');
downloadButton.innerText = 'Download Video';
// Buttons Container
buttonsContainer.style.right = '190px';
buttonsContainer.style.top = '10px';
buttonsContainer.style.position = 'absolute';
buttonsContainer.appendChild(button);
buttonsContainer.appendChild(downloadButton);
userMasthead.parentNode.insertBefore(buttonsContainer, userMasthead.nextSibling);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment