Advanced YouTube Age Restriction Bypass Pro

Watch age-restricted YouTube videos without login or age verification 😎 with enhanced features!

当前为 2025-01-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Advanced YouTube Age Restriction Bypass Pro
  3. // @description Watch age-restricted YouTube videos without login or age verification 😎 with enhanced features!
  4. // @version 4.1.1
  5. // @author Zerody (Enhanced by Cody)
  6. // @namespace https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/
  7. // @supportURL https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/issues
  8. // @license MIT
  9. // @match https://www.youtube.com/*
  10. // @match https://www.youtube-nocookie.com/*
  11. // @match https://m.youtube.com/*
  12. // @match https://music.youtube.com/*
  13. // @grant none
  14. // @run-at document-start
  15. // @compatible chrome
  16. // @compatible firefox
  17. // @compatible opera
  18. // @compatible edge
  19. // @compatible safari
  20. // ==/UserScript==
  21.  
  22. (function () {
  23. 'use strict';
  24.  
  25. // Configuration constants
  26. const CONFIG = {
  27. ENABLE_UNLOCK_NOTIFICATION: true,
  28. ENABLE_AUTO_AD_SKIPPER: true,
  29. DEFAULT_VIDEO_QUALITY: '1080p', // Options: '144p', '240p', '360p', '480p', '720p', '1080p', '4K'
  30. ENABLE_ERROR_REPORTING: true,
  31. COUNTRY_SPECIFIC_PROXIES: {
  32. US: 'https://us-proxy.server.com',
  33. EU: 'https://eu-proxy.server.com',
  34. },
  35. RATE_LIMIT_REQUESTS: 10,
  36. LOG_LEVEL: 'INFO', // Levels: INFO, WARN, ERROR
  37. };
  38.  
  39. const UNLOCKABLE_PLAYABILITY_STATUSES = ['AGE_VERIFICATION_REQUIRED', 'CONTENT_WARNING'];
  40. let rateLimitCount = 0;
  41.  
  42. const logger = {
  43. info: (msg) => logMessage('INFO', msg),
  44. warn: (msg) => logMessage('WARN', msg),
  45. error: (msg) => logMessage('ERROR', msg),
  46. };
  47.  
  48. function logMessage(level, msg) {
  49. const levels = ['INFO', 'WARN', 'ERROR'];
  50. if (levels.indexOf(level) >= levels.indexOf(CONFIG.LOG_LEVEL)) {
  51. console.log(`%cYouTube Bypass Pro [${level}]`, `color: ${getLogColor(level)};`, msg);
  52. }
  53. }
  54.  
  55. function getLogColor(level) {
  56. return {
  57. INFO: 'blue',
  58. WARN: 'orange',
  59. ERROR: 'red',
  60. }[level] || 'black';
  61. }
  62.  
  63. // Dynamic notification system
  64. function showNotification(message) {
  65. if (!CONFIG.ENABLE_UNLOCK_NOTIFICATION) return;
  66. const notification = document.createElement('div');
  67. notification.textContent = message;
  68. Object.assign(notification.style, {
  69. position: 'fixed',
  70. bottom: '10px',
  71. right: '10px',
  72. backgroundColor: '#007BFF',
  73. color: '#FFF',
  74. padding: '10px',
  75. borderRadius: '5px',
  76. zIndex: 9999,
  77. fontSize: '14px',
  78. });
  79. document.body.appendChild(notification);
  80. setTimeout(() => notification.remove(), 5000);
  81. }
  82.  
  83. // Country-specific proxy selection
  84. function getProxyForCountry(countryCode) {
  85. return CONFIG.COUNTRY_SPECIFIC_PROXIES[countryCode] || Object.values(CONFIG.COUNTRY_SPECIFIC_PROXIES)[0];
  86. }
  87.  
  88. // Auto-skip ads
  89. function enableAdSkipper() {
  90. if (!CONFIG.ENABLE_AUTO_AD_SKIPPER) return;
  91.  
  92. const observer = new MutationObserver((mutations) => {
  93. mutations.forEach(() => {
  94. const skipButton = document.querySelector('.ytp-ad-skip-button');
  95. if (skipButton) {
  96. skipButton.click();
  97. logger.info('Skipped an ad.');
  98. }
  99. });
  100. });
  101.  
  102. observer.observe(document.body, { childList: true, subtree: true });
  103. }
  104.  
  105. // Video quality enforcement
  106. function setDefaultVideoQuality() {
  107. const observer = new MutationObserver(() => {
  108. const settingsButton = document.querySelector('.ytp-settings-button');
  109. if (settingsButton) {
  110. settingsButton.click();
  111.  
  112. const interval = setInterval(() => {
  113. const qualityMenu = [...document.querySelectorAll('.ytp-menuitem')].find(
  114. (item) => item.textContent.includes(CONFIG.DEFAULT_VIDEO_QUALITY)
  115. );
  116. if (qualityMenu) {
  117. qualityMenu.click();
  118. logger.info(`Set video quality to ${CONFIG.DEFAULT_VIDEO_QUALITY}`);
  119. clearInterval(interval);
  120. }
  121. }, 200);
  122.  
  123. observer.disconnect();
  124. }
  125. });
  126.  
  127. observer.observe(document.body, { childList: true, subtree: true });
  128. }
  129.  
  130. // Error reporting
  131. function reportError(error) {
  132. if (!CONFIG.ENABLE_ERROR_REPORTING) return;
  133. fetch('https://error-reporting.server.com/report', {
  134. method: 'POST',
  135. headers: { 'Content-Type': 'application/json' },
  136. body: JSON.stringify({ error: error.message, timestamp: new Date().toISOString() }),
  137. });
  138. logger.error('Error reported to server.');
  139. }
  140.  
  141. // Unlock video response
  142. async function unlockResponse(response) {
  143. try {
  144. if (response.playabilityStatus && UNLOCKABLE_PLAYABILITY_STATUSES.includes(response.playabilityStatus.status)) {
  145. showNotification('Attempting to unlock video...');
  146. const proxy = getProxyForCountry('US');
  147.  
  148. const unlockedResponse = await fetch(`${proxy}/unlock`, {
  149. method: 'POST',
  150. headers: { 'Content-Type': 'application/json' },
  151. body: JSON.stringify({ videoId: response.videoDetails.videoId }),
  152. }).then((res) => res.json());
  153.  
  154. if (unlockedResponse.errorMessage) {
  155. throw new Error(unlockedResponse.errorMessage);
  156. }
  157.  
  158. Object.assign(response, unlockedResponse);
  159. logger.info('Video unlocked successfully.');
  160. showNotification('Video unlocked successfully!');
  161. }
  162. } catch (error) {
  163. logger.warn(`Proxy failed: ${error.message}. Retrying with fallback...`);
  164. const fallbackProxy = getProxyForCountry('EU');
  165. if (fallbackProxy) {
  166. unlockResponse({ ...response, proxy: fallbackProxy });
  167. } else {
  168. reportError(error);
  169. logger.error(`Failed to unlock video: ${error.message}`);
  170. showNotification('Failed to unlock video.');
  171. }
  172. }
  173. }
  174.  
  175. // Hook into XMLHttpRequest.open
  176. const nativeXHROpen = XMLHttpRequest.prototype.open;
  177. XMLHttpRequest.prototype.open = function (method, url, ...args) {
  178. if (url.includes('/youtubei/v1/player')) {
  179. this.addEventListener('readystatechange', function () {
  180. if (this.readyState === 4 && this.status === 200) {
  181. try {
  182. const response = JSON.parse(this.responseText);
  183. unlockResponse(response);
  184. this.responseText = JSON.stringify(response);
  185. } catch (err) {
  186. logger.error('Error processing video response: ' + err.message);
  187. }
  188. }
  189. });
  190. }
  191. nativeXHROpen.call(this, method, url, ...args);
  192. };
  193.  
  194. // Initialize script features
  195. function init() {
  196. logger.info('Initializing Advanced YouTube Bypass Pro...');
  197. enableAdSkipper();
  198. setDefaultVideoQuality();
  199. logger.info('Features initialized successfully!');
  200. }
  201.  
  202. init();
  203. })();