Advanced YouTube Age Restriction Bypass

Bypass YouTube age restrictions for test purposes only.

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Advanced YouTube Age Restriction Bypass
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  Bypass YouTube age restrictions for test purposes only.
// @author       Your Name
// @match        *://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  // Helper function to log debug messages
  function log(message) {
    console.log(`[YouTube Bypass]: ${message}`);
  }

  // Hook into YouTube's internal API requests
  (function interceptXHR() {
    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
      if (url.includes('/youtubei/v1/player')) {
        log('Intercepted request to /youtubei/v1/player');
        // Modify the response to bypass age restrictions
        this.addEventListener('load', function() {
          const response = JSON.parse(this.responseText);
          if (response.playabilityStatus.status === 'restricted') {
            response.playabilityStatus.status = 'OK';
            log('Bypassed age restriction!');
          }
        });
      }
      return originalOpen.apply(this, arguments);
    };
  })();

  // MutationObserver to monitor dynamic page changes
  const observer = new MutationObserver(() => {
    if (document.querySelector('ytd-watch-flexy[is-restricted]')) {
      log('Detected restricted video player. Attempting bypass...');
      // Inject the override script after a short delay to ensure the player is fully loaded
      setTimeout(injectOverrideScript, 1000);
    }
  });

  observer.observe(document.body, { childList: true, subtree: true });

  // Function to inject an override script directly into the page
  function injectOverrideScript() {
    const script = document.createElement('script');
    script.innerHTML = `(function() {
      const originalPlayer = window.ytPlayerConfig;
      if (originalPlayer && originalPlayer.args) {
        originalPlayer.args.raw_player_response.playabilityStatus.status = 'OK';
        console.log('[YouTube Bypass]: Player configuration modified.');
      }
    })();`;
    document.body.appendChild(script);
  }
})();