Registrati Accedi
n/program · 2025-09-02 · Modificato · 984 visualizzazioni
u/9thPlatino
n/programu/9th · 2025-09-02

防 切屏检测 脚本,可以用于某些神秘活动,理论上是通用的

@wangyou

注意浏览器要开开发者模式,不然油猴脚本都是不生效的
理论上是通用的,其他检测切屏的场景也可以用,自行修改匹配的(@match部分)域名即可,
如需完整活动教程,可看飞书:https://acn4gjw5vke5.feishu.cn/wiki/DQIVw8GUbi4wkakFf5xc2eWdn2g
[upvote]

// ==UserScript==
// @name         防切屏检测
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  阻止各类切屏检测
// @author       4P
// @match        https://connect.huaweicloud.com/courses/exam/*
// @match        https://edu.huaweicloud.com/certifications/*
// @match        https://edu.huaweicloud.com/signup/*
// @match        https://www.huaweicloud.com
// @run-at       document-start
// @grant        unsafeWindow
// @license      gpl-3.0
// ==/UserScript==

(function () {
    'use strict';
    const window = unsafeWindow;
    const blackList = new Set(["visibilitychange", "blur", "pagehide", "mouseleave"]);
    const isDebug = false;
    const log = console.log.bind(console, "[阻止切屏检测]");
    const debug = isDebug ? log : () => { };
    function patchToString(obj, ref) {
        return; // Not enabled for now
        obj.toString = () => ref.toString();
        obj.toString.toString = () => ref.toString.toString();
        obj.toString.toString.toString = obj.toString.toString;
    }
    function patchAddEventListener(obj, name) {
        obj._addEventListener = obj.addEventListener;
        obj.addEventListener = (...args) => {
            if (!blackList.has(args[0])) {
                debug(`allow ${name}.addEventListener`, ...args);
                return obj._addEventListener(...args);
            } else {
                log(`block ${name}.addEventListener`, ...args);
                return undefined;
            }
        };
        patchToString(obj.addEventListener, obj._addEventListener);
    }
    patchAddEventListener(window, "window");
    patchAddEventListener(document, "document");
    document.addEventListener("DOMContentLoaded", () => {
        patchAddEventListener(document.body, "document.body");
    }, { once: true, passive: true, capture: true });
    log("addEventListener hooked!");
    if (isDebug) { // DEBUG ONLY: find out all timers
        window._setInterval = window.setInterval;
        window.setInterval = (...args) => {
            const id = window._setInterval(...args);
            debug("calling window.setInterval", id, ...args);
            return id;
        };
        debug("setInterval hooked!");
        window._setTimeout = window.setTimeout;
        window.setTimeout = (...args) => {
            const id = window._setTimeout(...args);
            debug("calling window.setTimeout", id, ...args);
            return id;
        };
        debug("setTimeout hooked!");
    }
    Object.defineProperties(document, {
        hidden: {
            value: false
        },
        visibilityState: {
            value: "visible"
        },
        hasFocus: {
            value: () => true
        },
        onvisibilitychange: {
            get: () => undefined,
            set: () => { }
        },
        onblur: {
            get: () => undefined,
            set: () => { }
        },
        onmouseleave: {
            get: () => undefined,
            set: () => { }
        },
    });
    log("document properties set!");
    Object.defineProperties(window, {
        onblur: {
            get: () => undefined,
            set: () => { }
        },
        onpagehide: {
            get: () => undefined,
            set: () => { }
        },
    });
    log("window properties set!");
})();

[/upvote]

15
78
Accedi per partecipare alla discussione.
海外原生IP VPS,稳定访问全球网络

还在为IP不纯、平台风控、频繁验证而烦恼? 丽萨主机海外原生IP VPS,双ISP住宅IP,覆盖美国、香港、日本、新加坡、台湾、德国、越南、英国等热门地区,适合跨境电商、社媒运营、AI工具、流媒体及海外业务使用。

lisahost.com Scopri di più

78 risposte

Ordinamento
  1. tianzi Ricco sfondato Diamante 2025-09-02 #2

    必须点赞

    1
  2. local 💬 Diamante 2 ANNI 2025-09-02 #3

    已经有人举报到官方了

    0
  3. tzamc Oro 2025-09-02 #4

    赞一个,之前用的失效了。试试这个。

    0
  4. 9th Platino OP 2025-09-02 #5
    Rispondi @local: 已经有人举报到官方了

    就是说嘛,这就是需要登录才可以看的原因,即使这种情况下,还是会有人告状。

    0
  5. YearLater Oro 2025-09-02 #6

    感谢分享,很有用的脚本

    0
  6. tianzi Ricco sfondato Diamante 2025-09-02 #8
    Rispondi @local: 已经有人举报到官方了

    这不是害人吗?举报有啥好处?能让人不当人

    0
  7. ax570383885 Platino Non abbandonarsi mai 2025-09-02 #9

    好像有点作用

    0
  8. 9th Platino OP 2025-09-02 #10
    Rispondi @YearLater: 那么就搞成回复才能看

    有道理

    0
  9. 9th Platino OP 2025-09-02 #11
    Rispondi @tianzi: 这不是害人吗?举报有啥好处?能让人不当人

    天下熙熙,皆为利来;天下攘攘,皆为利往。涉及到AFF其中就有利益,有利益就会有人心理不舒服,就是这么回事,有人觉得你写了一个教程,或者什么脚本,吸引了很多人走AFF,心理不平衡,就去举报咯

    0
  10. lijun_shen Oro 2025-09-02 #13

    我瞅瞅

    0
  11. lijun_shen Oro 2025-09-02 #14
    Rispondi @lijun_shen: 我瞅瞅

    群里有坏人

    0
  12. zhangyx Maestro 2 ANNI 2025-09-02 #15

    看看是啥

    0
  13. ae80 Oro Non abbandonarsi mai 2025-09-02 #16

    谢谢分享

    0
  14. jl_luo Bronzo 2025-09-02 #17

    感谢分享

    0
  15. DeeDee Oro Non abbandonarsi mai 2025-09-02 #18

    这必须收藏了

    0
  16. lbj Platino 3 ANNI 2025-09-02 #19

    应该有用

    0
  17. spl Argento 2025-09-02 #20

    看看看看

    0
  18. cs9u Diamante Membro Diamante 2025-09-02 #21

    谢谢分享

    0
  19. LITNEWWA Oro Non abbandonarsi mai 2025-09-02 #22

    感谢大佬分享

    0
  20. meiyi Oro 2025-09-02 #23

    看看

    1
  21. azhao599998 Oro Salute e serenità per la Festa delle Barche Drago 2025-09-02 #24

    非常棒谢谢分享

    1
  22. Yizong Oro 2025-09-02 #25

    感谢啊啊啊

    0
  23. kof97zip Diamante 2025-09-03 #26

    防切屏?

    0
  24. 9th Platino OP 2025-09-03 #27
    Rispondi @kof97zip: 防切屏?

    防 切屏检测

    0
  25. zhxhwyzh14 Platino 3 ANNI 2025-09-03 #28

    看看是啥

    0
  26. yyzhou94 Oro 2025-09-03 #29
    Questa risposta è stata eliminata da un moderatore
  27. yyzhou94 Oro 2025-09-03 #30

    为大佬点赞

    0