// ==UserScript== // @name 夸克懒得点 (屏蔽版) // @namespace https://greasyfork.org/users/158417 // @version 0.19 // @description 夸克懒得点.. 修复误判,组合“头像Hash+昵称”进行精准屏蔽 // @author JIEMO // @match *://pan.quark.cn/* // @icon https://pan.quark.cn/favicon.ico // @license GPL-3.0 License // @run-at document-end // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 数据存储键名 (升级为v2,避免与旧版纯Hash数据冲突) const STORAGE_KEY = "blocked_users_v2"; const DEFAULT_BLOCKED = []; // ============================================================ // 1. 基础工具 // ============================================================ function getBlockedList() { return GM_getValue(STORAGE_KEY, DEFAULT_BLOCKED); } function setBlockedList(list) { GM_setValue(STORAGE_KEY, list); } // 字符串转 Hash 算法 function computeStringHash(str) { if (!str) return "null"; let hash = 0; for (let i = 0; i < str.length; i++) { const char = str.charCodeAt(i); hash = (hash << 5) - hash + char; hash |= 0; } return "u" + Math.abs(hash); } // ============================================================ // 2. 核心逻辑:提取分享者信息 // ============================================================ // 获取【分享信息区域】内的完整特征 function getTargetSharerInfo() { // 1. 定位分享信息容器 (关键!限定范围) const shareContainer = document.querySelector('.share-info-wrap'); if (!shareContainer) { return null; } // 2. 获取头像 Hash const imgElement = shareContainer.querySelector('img'); if (!imgElement || !imgElement.src) { return null; } const hashID = computeStringHash(imgElement.src); // 3. 获取用户昵称 // 根据你的需求:
const nameElement = shareContainer.querySelector('.author-name'); let nickName = "Unknown"; if (nameElement) { nickName = nameElement.innerText.trim(); } else { // 备用方案:有时候可能没有author-name类,尝试找类似结构的文本 const possibleNames = shareContainer.querySelectorAll('div'); if(possibleNames.length > 1) { nickName = possibleNames[1].innerText.trim(); // 盲猜第二个div是名字 } } // 在控制台打印,方便调试 console.log(`[夸克懒得点] 捕获分享者: [昵称: ${nickName}] [Hash: ${hashID}]`); return { name: nickName, hash: hashID }; } // ============================================================ // 3. UI 交互 // ============================================================ function showBlockedOverlay(user) { var overlay = document.createElement('div'); Object.assign(overlay.style, { position: 'fixed', top: '0', left: '0', width: '100%', height: '100%', backgroundColor: 'rgba(0, 0, 0, 0.95)', zIndex: '999999', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }); var text = document.createElement('h1'); text.innerText = "⚠️ 已屏蔽该分享者"; text.style.cssText = "color: red; font-size: 60px; font-weight: bold; text-shadow: 2px 2px 10px black; margin: 0;"; var subText = document.createElement('div'); subText.innerHTML = `昵称:${user.name}
Hash:${user.hash}
`; subText.style.textAlign = 'center'; subText.style.marginTop = '20px'; var unlockBtn = document.createElement('button'); unlockBtn.innerText = "本次临时允许 (点击消失)"; unlockBtn.style.cssText = "margin-top: 30px; padding: 10px 20px; cursor: pointer; background: #333; color: #fff; border: 1px solid #666;"; unlockBtn.onclick = function() { overlay.remove(); }; overlay.appendChild(text); overlay.appendChild(subText); overlay.appendChild(unlockBtn); document.body.appendChild(overlay); } function registerMenus() { // 菜单:屏蔽当前 GM_registerMenuCommand("🚫 屏蔽当前分享者 (昵称+头像)", function() { const currentUser = getTargetSharerInfo(); if (!currentUser) { alert("❌ 无法定位 .share-info-wrap 区域。\n请确保页面已加载完毕,且当前是分享详情页。"); return; } const list = getBlockedList(); // 检查是否已存在 (必须名字和Hash都相同) const exists = list.some(u => u.name === currentUser.name && u.hash === currentUser.hash); if (exists) { alert(`用户 [${currentUser.name}] 已经在屏蔽列表中了。`); } else { list.push(currentUser); setBlockedList(list); if(confirm(`✅ 已添加屏蔽!\n\n昵称: ${currentUser.name}\nHash: ${currentUser.hash}\n\n是否立即刷新生效?`)) { location.reload(); } } }); // 菜单:管理 GM_registerMenuCommand("📋 管理屏蔽列表", function() { const list = getBlockedList(); if (list.length === 0) { alert("屏蔽列表为空。"); return; } // 构建显示列表 let msg = "当前屏蔽列表 (请输入【序号】进行删除):\n----------------------\n"; list.forEach((u, index) => { msg += `【${index + 1}】 昵称: ${u.name} (Hash: ${u.hash})\n`; }); const input = prompt(msg + "\n----------------------\n请输入要删除的序号 (例如 1):"); if (input) { const index = parseInt(input) - 1; if (!isNaN(index) && index >= 0 && index < list.length) { const removed = list.splice(index, 1); setBlockedList(list); alert(`✅ 已移除: ${removed[0].name}\n刷新生效。`); location.reload(); } else { alert("❌ 序号无效。"); } } }); } registerMenus(); // ============================================================ // 4. 主程序执行 // ============================================================ // 场景1:分享页面 if (window.location.href.startsWith("https://pan.quark.cn/s/")) { window.onload = function() { // 稍微增加延迟,确保 share-info-wrap 渲染完成 setTimeout(function() { // --- 步骤 A: 获取当前分享者信息 --- const currentUser = getTargetSharerInfo(); // --- 步骤 B: 检查屏蔽列表 --- if (currentUser) { const blockedList = getBlockedList(); // 核心判断:必须昵称和Hash同时匹配才算命中 const isBlocked = blockedList.some(u => u.name === currentUser.name && u.hash === currentUser.hash); if (isBlocked) { console.warn(`[夸克懒得点] 触发屏蔽!用户: ${currentUser.name}`); showBlockedOverlay(currentUser); return; // ⛔ 阻断后续操作 } } else { console.log("[夸克懒得点] 未检测到分享者信息区域,跳过屏蔽检查。"); } // --- 步骤 C: 自动转存 (未屏蔽时执行) --- console.log("[夸克懒得点] 检查通过,执行自动转存..."); // 1. 勾选文件 var checkboxElement = document.querySelector('.ant-checkbox-input'); try { if (checkboxElement && !checkboxElement.checked) { checkboxElement.click(); } } catch (error) { console.error(error); } // 2. 点击保存 var saveButtonElement = document.querySelector('.share-save'); if (saveButtonElement) { saveButtonElement.click(); } else { var saveButtonElement2 = document.querySelector('.file-info_r'); if (saveButtonElement2) { saveButtonElement2.click(); } } // 3. 确认与跳转 setTimeout(function() { var confirmButtonElement = document.querySelector('.confirm-btn'); if (confirmButtonElement) { confirmButtonElement.click(); } var intervalId = setInterval(function() { var viewButtonElement = document.querySelector('.path'); if (viewButtonElement) { viewButtonElement.click(); clearInterval(intervalId); } }, 1000); }, 1000); }, 1500); }; } // 场景2:列表页面 (保持原样) if (window.location.href.startsWith("https://pan.quark.cn/list")) { window.onload = function() { setTimeout(function() { var checkboxElement = document.querySelector('.ant-checkbox-wrapper'); try { if(checkboxElement) checkboxElement.click(); } catch (error) {} }, 1000); }; } })();