// ==UserScript==
// @name Advanced YouTube Age Restriction Bypass Pro
// @description Watch age-restricted YouTube videos without login or age verification 😎 with enhanced features!
// @version 4.2.0
// @author Zerody (Enhanced by Cody)
// @namespace https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/
// @supportURL https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/issues
// @license MIT
// @match https://www.youtube.com/*
// @match https://www.youtube-nocookie.com/*
// @match https://m.youtube.com/*
// @match https://music.youtube.com/*
// @grant none
// @run-at document-start
// @compatible chrome
// @compatible firefox
// @compatible opera
// @compatible edge
// @compatible safari
// ==/UserScript==
(function () {
'use strict';
const CONFIG = {
ENABLE_UNLOCK_NOTIFICATION: true,
ENABLE_AUTO_AD_SKIPPER: true,
DEFAULT_VIDEO_QUALITY: '1080p',
ENABLE_ERROR_REPORTING: true,
COUNTRY_SPECIFIC_PROXIES: {
US: 'https://us-proxy.server.com',
EU: 'https://eu-proxy.server.com',
},
RATE_LIMIT_REQUESTS: 10,
LOG_LEVEL: 'INFO',
};
const UNLOCKABLE_STATUSES = ['AGE_VERIFICATION_REQUIRED', 'CONTENT_WARNING'];
let activeObservers = [];
const logger = {
info: (msg) => logMessage('INFO', msg),
warn: (msg) => logMessage('WARN', msg),
error: (msg) => logMessage('ERROR', msg),
};
function logMessage(level, msg) {
if (['INFO', 'WARN', 'ERROR'].includes(level) && CONFIG.LOG_LEVEL === level) {
console.log(`[YouTube Bypass Pro - ${level}]`, msg);
}
}
function showNotification(message, timeout = 5000) {
if (!CONFIG.ENABLE_UNLOCK_NOTIFICATION) return;
const notification = document.createElement('div');
notification.textContent = message;
Object.assign(notification.style, {
position: 'fixed',
bottom: '10px',
right: '10px',
backgroundColor: '#007BFF',
color: '#FFF',
padding: '10px',
borderRadius: '5px',
zIndex: 9999,
fontSize: '14px',
});
document.body.appendChild(notification);
setTimeout(() => notification.remove(), timeout);
}
function getProxy(countryCode) {
return CONFIG.COUNTRY_SPECIFIC_PROXIES[countryCode] || Object.values(CONFIG.COUNTRY_SPECIFIC_PROXIES)[0];
}
async function unlockResponse(response) {
try {
if (response.playabilityStatus && UNLOCKABLE_STATUSES.includes(response.playabilityStatus.status)) {
showNotification('Unlocking video...');
const proxy = getProxy('US');
const unlockAttempt = await fetch(`${proxy}/unlock`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ videoId: response.videoDetails.videoId }),
});
const unlockedData = await unlockAttempt.json();
if (unlockedData.errorMessage) throw new Error(unlockedData.errorMessage);
Object.assign(response, unlockedData);
logger.info('Video unlocked successfully.');
showNotification('Video unlocked successfully!');
}
} catch (error) {
logger.warn(`Unlock failed: ${error.message}`);
showNotification('Video unlock failed. Retrying...');
}
}
const nativeXHROpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function (method, url, ...args) {
if (url.includes('/youtubei/v1/player')) {
this.addEventListener('readystatechange', function () {
if (this.readyState === 4 && this.status === 200) {
try {
const response = JSON.parse(this.responseText);
unlockResponse(response);
this.responseText = JSON.stringify(response);
} catch (error) {
logger.error(`Error modifying video response: ${error.message}`);
}
}
});
}
nativeXHROpen.call(this, method, url, ...args);
};
function enableAdSkipper() {
if (!CONFIG.ENABLE_AUTO_AD_SKIPPER) return;
const observer = new MutationObserver(() => {
const skipButton = document.querySelector('.ytp-ad-skip-button');
if (skipButton) {
skipButton.click();
logger.info('Skipped an ad.');
}
});
observer.observe(document.body, { childList: true, subtree: true });
activeObservers.push(observer);
}
function setVideoQuality() {
const observer = new MutationObserver(() => {
const settingsButton = document.querySelector('.ytp-settings-button');
if (settingsButton) {
settingsButton.click();
observer.disconnect();
setTimeout(() => {
const qualityOption = [...document.querySelectorAll('.ytp-menuitem')].find((item) =>
item.textContent.includes(CONFIG.DEFAULT_VIDEO_QUALITY)
);
if (qualityOption) qualityOption.click();
logger.info(`Set video quality to ${CONFIG.DEFAULT_VIDEO_QUALITY}`);
}, 200);
}
});
observer.observe(document.body, { childList: true, subtree: true });
activeObservers.push(observer);
}
function disconnectObservers() {
activeObservers.forEach((observer) => observer.disconnect());
activeObservers = [];
}
function init() {
logger.info('Initializing YouTube Age Bypass...');
enableAdSkipper();
setVideoQuality();
window.addEventListener('beforeunload', disconnectObservers);
logger.info('Initialization complete!');
}
init();
})();