NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name YouTube to YouTube No-Cookie Embed Player (OpenJS edition)
// @namespace https://gist.github.com/thedoggybrad/4e17b0046ce072afc3f31610dcdef32a
// @version 0.0.2ojs
// @description Automatically redirect YouTube video URLs to a much privacy-friendly viewer which is the No Cookie Official YouTube Embed. Enjoy YouTube videos with no ads and trackers.
// @author TheDoggyBrad Software Labs
// @match https://www.youtube.com/*
// @grant none
// @updateURL https://librespeed.elementfx.com/yttoytembed-cdn/youtube_to_youtube_no_cookie_embed_player_ojs.user.js
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function redirectToEmbed() {
// Get the current URL
let currentUrl = window.location.href;
// Check if the URL matches the YouTube video pattern
let match = currentUrl.match(/https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/);
if (match) {
let videoId = match[1];
let embedUrl = `https://www.youtube-nocookie.com/embed/${videoId}`;
if (window.location.href !== embedUrl) {
window.location.href = embedUrl;
}
}
}
redirectToEmbed();
const observer = new MutationObserver(() => {
redirectToEmbed();
});
observer.observe(document, { childList: true, subtree: true });
})();
// ==/UserScript==
(function() {
'use strict';
function redirectToEmbed() {
// Get the current URL
let currentUrl = window.location.href;
// Check if the URL matches the YouTube video pattern
let match = currentUrl.match(/https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/);
if (match) {
let videoId = match[1];
let embedUrl = `https://www.youtube-nocookie.com/embed/${videoId}`;
if (window.location.href !== embedUrl) {
window.location.href = embedUrl;
}
}
}
redirectToEmbed();
const observer = new MutationObserver(() => {
redirectToEmbed();
});
observer.observe(document, { childList: true, subtree: true });
})();