Display "https://www.youtube.com/watch?v=***********" of embedded YouTube videos.
目前為
// ==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.3
// @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';
a.style.fontSize = 'initial';
} 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';
a.style.fontSize = 'initial';
}
if (element.parentElement.children.length <= 2 && element.parentElement.parentElement) {
element = element.parentElement;
}
element.parentElement.insertBefore(a, element.nextSibling);
console.log('Detected URL: %s', elements[i].src);
}
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';
a.style.fontSize = 'initial';
} 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';
a.style.fontSize = 'initial';
}
if (element.parentElement.children.length <= 2 && element.parentElement.parentElement) {
element = element.parentElement;
}
element.parentElement.insertBefore(a, element.nextSibling);
console.log('Detected URL: %s', elements[i].src);
}
// 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';
a.style.fontSize = 'initial';
element.parentElement.insertBefore(a, element.nextSibling);
console.log('Detected URL: %s', elements[i].src);
}
var elements = document.querySelectorAll('embed[src*="//www.youtube-nocookie.com/v/"]');
for (var i = 0, element; element = elements[i]; i++) {
var a = document.createElement('a');
a.href = element.src.split('?')[0].replace(/-nocookie\.com\/v\//, '.com/watch?v=');
a.appendChild(document.createTextNode(a.href));
a.style.position = 'relative';
a.style.display = 'table';
a.style.fontSize = 'initial';
element.parentElement.insertBefore(a, element.nextSibling);
console.log('Detected URL: %s', elements[i].src);
}
});