Youtube to Invidio.us Embed

Forces all embedded Youtube videos to Invidio.us for watch youtube videos with more privacy

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name              Youtube to Invidio.us Embed
// @description       Forces all embedded Youtube videos to Invidio.us for watch youtube videos with more privacy
// @version           1.2
// @include           http*
// @exclude           *youtube.com/*
// @grant             none
// @namespace         https://greasyfork.org/users/433508
// ==/UserScript==

// Domain of Invidio instance, change by your prefer (Default: invidio.us)
var invidioUrl = 'invidio.us'; 

function noYt() {
	var i, attr, index, video, tag = document.getElementsByTagName('iframe');
					
	for (i = 0; i < tag.length; i++) {
		attr = tag[i].getAttribute('src');
		index = 0;
							
		if (attr.indexOf('youtube.com') !== -1) {						
			if (attr.indexOf('/v/') >= 0) {
				index = attr.indexOf('/v/') + 3;
			} else if(attr.indexOf('?v=') >= 0)  {
				index = attr.indexOf('?v=') + 3;
			} else if (attr.indexOf('/embed/') >= 0) {
				index = attr.indexOf('/embed/') + 7;							
			}
			
			video = attr.substring(index, index + 11);					
		}
			
		if (index > 0) {			
			tag[i].setAttribute('src', 'https://' + invidioUrl + '/embed/' + video);
			tag[i].setAttribute('style', 'min-height:100%; min-width:100%;');
			tag[i].setAttribute('frameborder', '0');
			tag[i].setAttribute('allowfullscreen', '1');
		}
	}
}

noYt();