video watch page URL

Display "https://www.youtube.com/watch?v=***********" of embedded YouTube videos.

Versión del día 31/1/2019. Echa un vistazo a la versión más reciente.

// ==UserScript==
// @name           video watch page URL
// @name:ja        埋め込み動画の動画元URL表示
// @namespace      https://greasyfork.org/users/19523
// @description    Display "https://www.youtube.com/watch?v=***********" of embedded YouTube videos.
// @description:ja ページに埋め込まれたYouTubeの動画の下に動画元のURLを付け加えます
// @include        *
// @exclude        http://www.youtube.com/*
// @exclude        https://www.youtube.com/*
// @version        0.2.1
// @grant          none
// ==/UserScript==


window.addEventListener('load', function () {

  var elements = document.querySelectorAll('iframe[src*="//www.youtube.com/embed/"]');
  for (var i = 0, element; element = elements[i]; i++) {
    var a = document.createElement('a');
    if (element.src.indexOf('videoseries') >= 0) {
      a.href = element.src.replace(/embed\/videoseries/, 'playlist');
      a.appendChild(document.createTextNode(a.href));
      a.style.position = 'relative';
      a.style.display = 'table';
      element.parentElement.insertBefore(a, element.nextSibling);
    } else {
      a.href = element.src.split('?')[0].replace(/embed\//, 'watch?v=');
      a.appendChild(document.createTextNode(a.href));
      a.style.position = 'relative';
      a.style.display = 'table';
      element.parentElement.insertBefore(a, element.nextSibling);
    }
  }

  var elements = document.querySelectorAll('iframe[src*="//www.youtube-nocookie.com/embed/"]');
  for (var i = 0, element; element = elements[i]; i++) {
    var a = document.createElement('a');
    if (element.src.indexOf('videoseries') >= 0) {
      a.href = element.src.replace(/-nocookie\.com\/embed\/videoseries/, '.com/playlist');
      a.appendChild(document.createTextNode(a.href));
      a.style.position = 'relative';
      a.style.display = 'table';
      element.parentElement.insertBefore(a, element.nextSibling);
    } else {
      a.href = element.src.split('?')[0].replace(/-nocookie\.com\/embed\//, '.com/watch?v=');
      a.appendChild(document.createTextNode(a.href));
      a.style.position = 'relative';
      a.style.display = 'table';
      element.parentElement.insertBefore(a, element.nextSibling);
    }
  }

  // Flash-embedded videos
  var elements = document.querySelectorAll('embed[src*="//www.youtube.com/v/"]');
  for (var i = 0, element; element = elements[i]; i++) {
    var a = document.createElement('a');
    a.href = element.src.split('?')[0].replace(/v\//, 'watch?v=');
    a.appendChild(document.createTextNode(a.href));
    a.style.position = 'relative';
    a.style.display = 'table';
    element.parentElement.insertBefore(a, element.nextSibling);
  }
});