Append embedded YouTube video URL

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

目前為 2019-01-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name           Append embedded YouTube video 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.1
// @grant          none
// ==/UserScript==


(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');
    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);
  }
})();