您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Replace YouTube embeds with yewtu.be embeds.
当前为
- // ==UserScript==
- // @name Invidious (yewtu.be) embed
- // @description Replace YouTube embeds with yewtu.be embeds.
- // @author Backend & SkauOfArcadia
- // @homepage https://skau.neocities.org/
- // @contactURL https://t.me/SkauOfArcadia
- // @include *
- // @exclude *://www.youtube.com/*
- // @exclude *://*.google.com/*
- // @exclude *://web.archive.org/web/*
- // @version 2.56
- // @namespace https://greasyfork.org/users/751327
- // ==/UserScript==
- var a = -1; //defines autoplay value on the initial page load
- var b = -1; //defines autoplay for embedded videos that appear on page interaction
- // -1 = will only autoplay if the embed has the "autoplay=1" parameter
- // 0 = disables autoplay
- // 1 = enables autoplay
- var observer = new MutationObserver(mutate);
- observer.observe(document, {
- childList: true,
- attributes: true,
- subtree: true
- });
- function mutate() {
- go(b);
- }
- function go(auto) {
- var frames = document.getElementsByTagName("iframe");
- frames = Object.values(frames).filter(youtubeiFrame);
- for (var i = 0; i < frames.length; i++) {
- var frame = frames[i];
- var src = frame.getAttribute('src');
- if (window.location.hostname.indexOf('duckduckgo.com') !== -1 && src.indexOf('/video_frame?url=') === 0) {
- src = decodeURIComponent(src.replace('/video_frame?url=', ''));
- }
- var invid = src.
- replace('www.', '').
- replace('youtube.com', 'yewtu.be').
- replace('youtube-nocookie.com', 'yewtu.be')
- .replace('youtu.be/', 'yewtu.be/embed/');
- let params = new URLSearchParams();
- if (invid.indexOf('?') !== -1) {
- params = new URLSearchParams(invid.split('?').pop());
- invid = invid.split('?')[0];
- params.delete('controls');
- }
- if (auto !== -1) {
- params.set('autoplay', auto);
- } else if (!params.get('autoplay')) {
- params.set('autoplay', 0);
- }
- if ((frame.width === '0' || frame.width === '1' || frame.style.width === '0px' || frame.style.width === '1px')
- && (frame.height === '0' || frame.height === '1' || frame.style.height === '0px' || frame.style.height === '1px')
- && params.get('autoplay') === '1') {
- params.set('listen', 1);
- }
- invid += '?' + params;
- frame.setAttribute('src', invid);
- }
- }
- function youtubeiFrame(el) {
- if (el.hasAttribute('src')) {
- return (el.getAttribute('src').indexOf('youtube') !== -1 || el.getAttribute('src').indexOf('youtu.be') !== -1);
- }
- return false;
- }
- go(a);