uView Plus Ad Bypass (VIP Simulation + Google Ads Blocker)

拦截 uView Plus 文档广告验证请求,模拟 VIP 响应,移除二维码弹窗及 Google 广告组件(AdSense、双击广告等)。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         uView Plus Ad Bypass (VIP Simulation + Google Ads Blocker)
// @namespace    https://uiadmin.net/
// @version      1.0.1
// @description  Bypass uView Plus documentation ad verification, block QR prompts, and remove Google ads (AdSense, DoubleClick, FundingChoices).
// @description:zh-CN  拦截 uView Plus 文档广告验证请求,模拟 VIP 响应,移除二维码弹窗及 Google 广告组件(AdSense、双击广告等)。
// @author       WanliZhong
// @license      MIT
// @homepage     https://uiadmin.net/
// @supportURL   https://uview-plus.jiangruyi.com/cooperation/about.html
// @match        https://uiadmin.net/*
// @match        https://*.uiadmin.net/*
// @match        https://uview-plus.jiangruyi.com/*
// @icon         https://uiadmin.net/favicon.ico
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // 模拟 VIP 接口返回
  const OriginalXHR = window.XMLHttpRequest;

  class InterceptedXHR extends OriginalXHR {
    open(method, url, ...rest) {
      this._isAdRequest = typeof url === 'string' && url.includes('/api/v1/wxapp/ad/add');
      this._adUrl = url;
      return super.open(method, url, ...rest);
    }

    send(body) {
      if (this._isAdRequest) {
        console.log('[AdBypass] 🚫 Intercepting ad request:', this._adUrl);

        let id = 'fake-id';
        try {
          const u = new URL(this._adUrl, location.origin);
          id = u.searchParams.get('id') || id;
        } catch (e) {
          console.warn('[AdBypass] ⚠️ Failed to parse ad URL:', e);
        }

        const fakeData = {
          code: 200,
          data: { isVip: true, id: id },
          msg: '成功',
          env: 'prod'
        };

        const fakeEvent = {
          target: {
            status: 200,
            readyState: 4,
            responseText: JSON.stringify(fakeData),
            response: JSON.stringify(fakeData)
          }
        };

        setTimeout(() => {
          if (typeof this.onload === 'function') this.onload(fakeEvent);
          if (typeof this.onreadystatechange === 'function') {
            this.readyState = 4;
            this.status = 200;
            this.responseText = fakeEvent.target.responseText;
            this.onreadystatechange(fakeEvent);
          }
        }, 100);

        return;
      }

      return super.send(body);
    }
  }

  window.XMLHttpRequest = InterceptedXHR;

  // 广告清理函数
  function cleanAllAds() {
    try {
      // 移除广告脚本
      document.querySelectorAll('script[src*="googlesyndication"], script[src*="fundingchoicesmessages"]').forEach(e => e.remove());
      // 移除广告 iframe
      document.querySelectorAll('iframe[src*="googlesyndication"], iframe[src*="doubleclick"]').forEach(e => e.remove());
      // 移除常见广告 DOM
      document.querySelectorAll('[class*="adsbygoogle"], [id*="adsbygoogle"], .fc-ab-root, .google-auto-placed, .ad-container')
        .forEach(e => e.remove());
    } catch (err) {
      console.warn('[AdBypass] ❌ Error cleaning ads:', err);
    }
  }

  // 页面加载后立即清除广告,并延迟几轮再次清除
  document.addEventListener('DOMContentLoaded', () => {
    cleanAllAds();
    setTimeout(cleanAllAds, 1000);
    setTimeout(cleanAllAds, 3000);
    setTimeout(cleanAllAds, 5000);
  });

  // 观察 DOM 动态插入内容
  function observeWhenBodyReady() {
    const interval = setInterval(() => {
      if (document.body) {
        const observer = new MutationObserver(() => cleanAllAds());
        observer.observe(document.body, { childList: true, subtree: true });
        clearInterval(interval);
      }
    }, 100);
  }

  observeWhenBodyReady();

  // 可选:屏蔽 alert 弹窗
  window.alert = function (message) {
    console.log("Blocked alert:", message);
    throw new Error("alert() was blocked to prevent interruption.");
  };
})();