洛谷反诈中心 2.1.2

· · 个人记录

洛谷反诈中心 2.1.2

3.0因为宇宙射线某些原因被我给搞没了……

手动反诈很麻烦而且还是容易被诈骗,所以我们用脚本来反诈。

https://www.bilibili.com/video/BV1GJ411x7h7/?spm_id_from=333.337.search-card.all.click
https://www.bilibili.com/video/BV1GJ411x7h7
https://noip.d0j1a1701.cc/
https://vdse.bdstatic.com/192d9a98d782d9c74c96f09db9378d93.mp4
https://cdn.luogu.com.cn/upload/image_hosting/216k1isp.png
https://www.ixigua.com/6656671797355741703?logTag=cbc208a92ff1fa10d8f1
https://kugou.com/song-36/2cklx51.html?from_360
https://y.qq.com/n/ryqq/songDetail/002Z6Nqx34XLgt?songtype=0&ADTAG=360ald
https://music.163.com/#/song?id=18520488
https://www.luogu.com.cn/user/677045
https://www.luogu.com.cn/paste/opkra6n0
https://www.luogu.com.cn/paste/t6xq1k38
https://p.qpic.cn/qq_expression/41384847/41384847_0_0_0_9710B2BF57B43E59DC64A5C64407F5B2_0_0/0
https://y.qq.com/n/ryqq/songDetail/0004gbRR1vKpcD
https://www.luogu.com.cn/problem/U334368
https://www.bilibili.com/video/BV1hq4y1s7VH/?spm_id_from=333.337.search-card.all.click

装好脚本以后你可以用一下链接测试(主要也是方便我测试):

诈骗链接1

诈骗链接2

诈骗链接3

代码(在油猴上运行):

// ==UserScript==
// @name         洛谷反诈中心
// @version      2.1.2
// @description  自动检测诈骗链接
// @match        https://www.luogu.com.cn/*
// @match        https://www.luogu.com.cn/user/*
// @match        https://www.luogu.com.cn/paste/*
// @match        https://www.luogu.com.cn/problem/*
// @match        https://www.luogu.com.cn/blog/*
// @author       GWBailang
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    const zhapianlianjie = GM_getValue('customLinks', []) || [];

    const popupStyle = `
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        padding: 10px;
        background-color: #fff;
        border: 1px solid #ccc;
        border-radius: 4px;
        z-index: 9999;
    `;

    document.addEventListener('mousemove', function(e) {
        const hoveredLink = e.target.closest('a');
        if (hoveredLink && isSpecifiedLink(hoveredLink.href)) {
            hoveredLink.addEventListener('mouseover', showPopup);
            hoveredLink.addEventListener('mouseout', hidePopup);
        }
    });

    document.addEventListener('keydown', function(e) {
        if (e.altKey && e.shiftKey && e.key === 'N') { // Alt+Shift+N
            e.preventDefault();
            e.stopPropagation();

            createManageLinksWindow();
        }
    });

    function isSpecifiedLink(linkUrl) {
        return zhapianlianjie.includes(linkUrl); // 检查链接是否为诈骗链接
    }

    function showPopup(event) {
        const hoveredLink = event.target.href;
        if (zhapianlianjie.includes(hoveredLink)) {
            alert("这是诈骗链接 "+hoveredLink);
        }
    }

    function hidePopup() {
        const popup = document.querySelector('.custom-links-popup');
        if (popup) {
            popup.remove();
        }
    }

    function createManageLinksWindow() {
        const windowStyle = `
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            padding: 10px;
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 4px;
            z-index: 9999;
        `;

        const backdropStyle = `
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 9998;
        `;

        const linksPopup = document.createElement('div');
        linksPopup.style.cssText = windowStyle;
        linksPopup.innerHTML = `
            <h3>管理诈骗链接</h3>
            <ul id="custom-links-list">
                ${zhapianlianjie.map(link => `<li>${link}</li>`).join('')}
            </ul>
            <input id="new-link-input" type="text" placeholder="输入诈骗链接">
            <button id="save-link-btn">确定</button>
        `;

        const backdrop = document.createElement('div');
        backdrop.style.cssText = backdropStyle;

        document.body.appendChild(backdrop);
        document.body.appendChild(linksPopup);

        const customLinksList = document.getElementById('custom-links-list');
        const newLinkInput = document.getElementById('new-link-input');
        const saveLinkBtn = document.getElementById('save-link-btn');

        saveLinkBtn.addEventListener('click', function() {
            const newLink = newLinkInput.value.trim();

            if (newLink) {
                if (zhapianlianjie.includes(newLink)) {
                    zhapianlianjie.splice(zhapianlianjie.indexOf(newLink), 1);
                } else {
                    zhapianlianjie.push(newLink);
                }
                GM_setValue('customLinks', zhapianlianjie); // 保存诈骗链接

                customLinksList.innerHTML = zhapianlianjie.map(link => `<li>${link}</li>`).join('');

                newLinkInput.value = '';
            }
        });

        document.addEventListener('click', function(e) {
            if (!linksPopup.contains(e.target)) {
                linksPopup.remove();
                backdrop.remove();
            }
        });
    }
})();

最后特别鸣谢 https://www.datuchat.com/,理解我说的意思+不胡说八道+代码逻辑清晰+码风好评。