跳到正文

剪贴板

剪贴板 0hoyf0r2

原文
剪贴板信息

剪贴板信息

收录
更新

// ==UserScript== // @name 洛谷强力学术 // @namespace http://tampermonkey.net/ // @version 1.0 // @auther Yt_4245 // @description 强制聚焦学习相关网站 // @match :///* // @grant none // @run-at document-start // ==/UserScript==

(function() { ‘use strict’;

// 允许的白名单规则 const ALLOW_RULES = [ // 洛谷核心功能 /^https://(www.)?luogu.com.cn/?$/i, // 首页 /^https://(www.)?luogu.com.cn/problem(/list)?/i, // 题目列表

代码
// DeepSeek 系列
/^https?:\/\/.*\.?deepseek\.com\/.*/i,

// 豆包系列
/^https?:\/\/.*\.?doubao\.com\/.*/i,

// 百度核心学习功能
/^https:\/\/fanyi\.baidu\.com\/.*/i,                               // 翻译
/^https:\/\/www\.baidu\.com\/s\?.*wd=.*/i,                         // 搜索(含关键词)
/^https:\/\/(ai|chat|knowledge)\.baidu\.com\/.*/i                   // AI相关

];

// 智能路径检测 function shouldAllow() { const currentURL = window.location.href.toLowerCase();

代码
// 白名单匹配检测
if (ALLOW_RULES.some(regex => regex.test(currentURL))) {
    return true;
}

// 特殊放行逻辑
if (currentURL.startsWith('https://www.luogu.com.cn/problem/')) {
    return true;  // 放行具体题目页
}

return false;

}

// 执行重定向逻辑 if (!shouldAllow()) { // 保留原网站信息用于调试 console.warn(‘[学术模式] 拦截非学习网站:’, window.location.href);

代码
// 清除当前页面内容
document.documentElement.innerHTML = '';

// 跳转至洛谷题库
window.location.replace('https://www.luogu.com.cn/problem/list');

} })();