Usable for copying a video ID to a clipboard for downloading via youtube-dl. By default it also prefixes the ID with "--" if it starts with a dash (this can be disabled).
当前为
// ==UserScript==
// @name YouTube - add video ID text field
// @namespace monnef.tk
// @description Usable for copying a video ID to a clipboard for downloading via youtube-dl. By default it also prefixes the ID with "--" if it starts with a dash (this can be disabled).
// @include http://www.youtube.com/watch*
// @include https://www.youtube.com/watch*
// @version 1
// @grant none
// @require http://code.jquery.com/jquery-2.1.3.min.js
// ==/UserScript==
// if you don't want prefixing, replace the word "true" with "false" on the next line
var prefixEnabled = true;
function textFieldClicked() {
var e = $(this);
e.select();
}
$("#movie_player").each(function() {
var e = $(this);
var urlMatch = window.location.href.match(/^.*watch(\?v=([^&]+)|\?(.*)).*$/);
if (urlMatch.length >= 2) {
var link = urlMatch[2];
if(prefixEnabled && link[0] === '-') link = "-- " + link;
e.parent().after($("<input />").attr("type", "text").attr("value", link).css("margin-top", "10px").css("border", "0").css("box-shadow", "0px 1px 2px rgba(0, 0, 0, 0.1)").css("font-size", "200%").click(textFieldClicked));
}
});