Forwards YouTube links to the youtube.com/embed/* page, so there's just the video in your window and nothing else.
当前为
// ==UserScript==
// @name YouTube /embed/ forwarder
// @description Forwards YouTube links to the youtube.com/embed/* page, so there's just the video in your window and nothing else.
// @namespace https://greasyfork.org/en/users/1148791-vuccala
// @author Vuccala
// @icon https://archive.org/download/yt_icon/yt.png
// @match *://*.youtube.com/*
// @match *://*.youtu.be/*
// @run-at document-start
// @version 0.5
// @grant none
// @license MIT
// ==/UserScript==
(function () {
const embedBaseUrl = 'https://www.youtube.com/embed/';
function getId(u) {
const idMatch = /(?:[?&]v=|\/(?:embed\/|v\/|shorts\/))([^&?/]+)/.exec(u);
return idMatch ? idMatch[1] : '';
}
function createSpoofPage(embedUrl) {
const html = `
<html style="background-color: #000;">
<head>
<meta http-equiv="refresh" content="0; url='${embedUrl}'" />
<meta name="referrer" content="origin" />
</head>
<body style="background-color: #000; color: #aaa;">
<p>Redirecting to YouTube embed...</p>
</body>
</html>
`;
const blob = new Blob([html], { type: 'text/html' });
return URL.createObjectURL(blob);
}
const url = window.location.href;
if (url.includes('/watch?v=') || url.includes('/shorts/') || url.includes('/watch?app=desktop&v=')) {
const videoId = getId(url);
const embedUrl = embedBaseUrl + videoId;
if (embedUrl !== url) {
const spoofPage = createSpoofPage(embedUrl);
window.location.href = spoofPage;
}
}
})();