洛谷反诈中心

反诈!!!

目前为 2024-10-15 提交的版本。查看 最新版本

// ==UserScript==
// @name         洛谷反诈中心
// @namespace    http://tampermonkey.net/
// @version      2024-10-15-2
// @description  反诈!!!
// @author       _s_z_y_
// @match        https://www.luogu.com.cn/*
// @match        https://www.luogu.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=143.113
// @license MIT
// @grant        none
// ==/UserScript==

let targetStrings = JSON.parse(localStorage.getItem('targetStrings')) || ['bilibili', 'mihoyo'];

const tooltip = document.createElement('div');
tooltip.style.position = 'absolute';
tooltip.style.backgroundColor = 'black';
tooltip.style.color = 'white';
tooltip.style.padding = '5px';
tooltip.style.borderRadius = '5px';
tooltip.style.display = 'none';
tooltip.style.zIndex = '10000';
document.body.appendChild(tooltip);

function handleMouseOver(event) {
    const link = event.target.closest('a');
    if (link && link.href) {
        targetStrings.forEach(targetString => {
            if (link.href.includes(targetString)) {
                tooltip.innerText = `疑似诈骗链接: ${targetString}`;
                tooltip.style.display = 'block';
                tooltip.style.left = `${event.pageX + 10}px`;
                tooltip.style.top = `${event.pageY + 10}px`;
            }
        });
    }
}

function handleMouseOut() {
    tooltip.style.display = 'none';
}

document.addEventListener('mousemove', function (event) {
    handleMouseOver(event);
});

document.addEventListener('mouseout', handleMouseOut);

document.addEventListener('keydown', function (e) {
    if (e.ctrlKey && e.key === 'm') {
        e.preventDefault();
        showEditUI();
    }
});

function showEditUI() {
    if (document.getElementById('editUI')) return;
    const editUI = document.createElement('div');
    editUI.id = 'editUI';
    editUI.style.position = 'fixed';
    editUI.style.top = '50%';
    editUI.style.left = '50%';
    editUI.style.transform = 'translate(-50%, -50%)';
    editUI.style.zIndex = '10000';
    editUI.style.backgroundColor = 'white';
    editUI.style.border = '1px solid black';
    editUI.style.padding = '20px';
    editUI.style.boxShadow = '0px 0px 10px rgba(0,0,0,0.5)';

    const instructions = document.createElement('p');
    instructions.innerText = '关键词列表(半角逗号间隔):';
    editUI.appendChild(instructions);

    const inputField = document.createElement('textarea');
    inputField.value = targetStrings.join(', ');
    inputField.style.width = '300px';
    inputField.style.height = '100px';
    editUI.appendChild(inputField);

    const saveButton = document.createElement('button');
    saveButton.innerText = 'Save';
    saveButton.style.marginTop = '10px';
    saveButton.onclick = () => {
        targetStrings = inputField.value.split(',').map(str => str.trim());
        localStorage.setItem('targetStrings', JSON.stringify(targetStrings));
        alert('Target strings updated: ' + targetStrings.join(', '));
        document.body.removeChild(editUI);
    };
    editUI.appendChild(saveButton);

    const cancelButton = document.createElement('button');
    cancelButton.innerText = 'Cancel';
    cancelButton.style.marginTop = '10px';
    cancelButton.style.marginLeft = '10px';
    cancelButton.onclick = () => {
        document.body.removeChild(editUI);
    };
    editUI.appendChild(cancelButton);

    document.body.appendChild(editUI);
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址