您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
一点小小hook
当前为
// ==UserScript== // @name 更好访问gcc // @namespace http://tampermonkey.net/ // @version 1.9 // @description 一点小小hook // @author LinXingJun // @match *://*.gcc.edu.cn/* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; // 配置重定向规则 const redirect_url = { 'nc.gcc.edu.cn': 'nic.gcc.edu.cn', 'www-cnki-net.vpn.gcc.edu.cn': 'www-cnki-net-s.vpn.gcc.edu.cn', 'navi-cnki-net-s.vpn.gcc.edu.cn:8118': 'navi.cnki.net' }; const blockblackkeyword = ["vpn","mail"]; if (window.location.protocol === 'https:') { redirect_url['http:'] = 'https:'; } // 当前页面URL替换与跳转 function handlePageRedirect() { let newUrl = location.href; for (const [oldKey, newKey] of Object.entries(redirect_url)) { if (newUrl.includes(oldKey)) { newUrl = newUrl.replace(oldKey, newKey); location.replace(newUrl); break; } } } // 替换页面资源引用 function replaceResourceUrls() { // 需要处理的标签属性 const targets = [ { selector: 'a', attr: 'href' }, { selector: 'img', attr: 'src' }, { selector: 'script', attr: 'src' }, { selector: 'link', attr: 'href' } ]; targets.forEach(target => { document.querySelectorAll(target.selector).forEach(el => { const attrValue = el.getAttribute(target.attr); if (attrValue) { for (const [oldKey, newKey] of Object.entries(redirect_url)) { if (attrValue.includes(oldKey)) { el.setAttribute( target.attr, attrValue.replace(oldKey, newKey) ); break; } } } }); }); } // 屏蔽原生跳转(通过代理 a 标签点击事件) function blockNativeRedirects() { document.addEventListener('click', (e) => { if (e.target.tagName === 'A') { const href = e.target.getAttribute('href'); if (href && !href.startsWith('#')) { e.preventDefault(); // 手动处理跳转 window.location.href = href; } } }); } //vpn 503的时候重新刷新 if (document.body.innerText.includes("Server is unable to process client's requests temporarily due to overload or system maintenance")) { location.reload(); } if (!blockblackkeyword.some(keyword => location.href.includes(keyword))) { // 执行主流程 handlePageRedirect(); replaceResourceUrls(); blockNativeRedirects(); // 监听DOM变化处理动态内容 const observer = new MutationObserver(() => { replaceResourceUrls(); }); observer.observe(document.body, { childList: true, subtree: true }); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址