Greasy Fork

Greasy Fork is available in English.

隐藏继续使用 Google 搜索前须知

隐藏继续使用 Google 搜索前须知的弹出提示

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         隐藏继续使用 Google 搜索前须知
// @version      1.0
// @description  隐藏继续使用 Google 搜索前须知的弹出提示
// @author       ChatGPT
// @match        *://www.google.co.jp/*
// @match        *://www.google.com.hk/*
// @match        *://www.google.com/*
// @run-at       document-start
// @namespace http://greasyfork.icu/users/452911
// ==/UserScript==

(function() {
    'use strict';

    // 定义一个计数器,用来记录执行次数
    let count = 0;

    // 设置定时器,每隔300毫秒执行一次
    let intervalId = setInterval(function() {
        // 执行的脚本逻辑
        document.querySelectorAll('button, a').forEach(element => {
            if (element.textContent.includes('继续阅读') || element.textContent.includes('全部拒绝')) {
                element.click();
            }
        });

        // 每执行一次计数器加1
        count++;

        // 如果执行了10次,清除定时器
        if (count === 10) {
            clearInterval(intervalId);
        }
    }, 300);

    // 添加隐藏元素的样式
    let style = document.createElement('style');
    style.innerHTML = `[aria-label='继续使用 Google 搜索前须知'] {display: none !important; visibility: hidden; opacity: 0; z-index: -999; width: 0; height: 0; pointer-events: none; position: absolute; left: -9999px; top: -9999px;}`;
    document.head.appendChild(style);

})();