// ==UserScript== // @name 移动版网站自动跳转到电脑版 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 自动将移动版网站重定向到对应的电脑版 // @author Claude // @match *://m.thepaper.cn/* // @match *://m.huaban.com/* // @match *://m.manhuagui.com/* // @match *://m.duitang.com/* // @match *://m.douban.com/* // @match *://m.zhipin.com/* // @match *://m.jiemian.com/* // @match *://m.weibo.cn/* // @match *://m.cnbeta.com.tw/* // @match *://m.ac.qq.com/* // @match *://m.hupu.com/* // @grant none // @run-at document-start // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 当前URL const currentURL = window.location.href; let desktopURL = ''; // 简单替换"m."为空的网站 const simpleDomains = [ 'thepaper.cn', 'huaban.com', 'manhuagui.com', 'duitang.com', 'douban.com', 'zhipin.com', 'jiemian.com' ]; // 处理简单替换的情况 for (const domain of simpleDomains) { if (currentURL.includes(`m.${domain}`)) { desktopURL = currentURL.replace(`m.${domain}`, domain); break; } } // 特殊情况处理 // m.weibo.cn -> weibo.com if (currentURL.includes('m.weibo.cn')) { desktopURL = currentURL.replace('m.weibo.cn', 'weibo.com'); } // m.cnbeta.com.tw/view/XXXX.htm -> www.cnbeta.com.tw/articles/tech/XXXX.htm else if (currentURL.match(/m\.cnbeta\.com\.tw\/view\/(\d+)\.htm/)) { const id = currentURL.match(/m\.cnbeta\.com\.tw\/view\/(\d+)\.htm/)[1]; desktopURL = `https://www.cnbeta.com.tw/articles/tech/${id}.htm`; } // m.ac.qq.com/chapter/index/id/XXX/cid/YYY -> ac.qq.com/ComicView/index/id/XXX/cid/YYY else if (currentURL.match(/m\.ac\.qq\.com\/chapter\/index\/id\/(\d+)\/cid\/(\d+)/)) { const matches = currentURL.match(/m\.ac\.qq\.com\/chapter\/index\/id\/(\d+)\/cid\/(\d+)/); const id = matches[1]; const cid = matches[2]; desktopURL = `https://ac.qq.com/ComicView/index/id/${id}/cid/${cid}`; } // m.ac.qq.com/comic/index/id/XXX -> ac.qq.com/Comic/comicInfo/id/XXX else if (currentURL.match(/m\.ac\.qq\.com\/comic\/index\/id\/(\d+)/)) { const id = currentURL.match(/m\.ac\.qq\.com\/comic\/index\/id\/(\d+)/)[1]; desktopURL = `https://ac.qq.com/Comic/comicInfo/id/${id}`; } // m.hupu.com/bbs/XXX -> bbs.hupu.com/XXX.html else if (currentURL.match(/m\.hupu\.com\/bbs\/(\d+)/)) { const id = currentURL.match(/m\.hupu\.com\/bbs\/(\d+)/)[1]; desktopURL = `https://bbs.hupu.com/${id}.html`; } // 如果匹配到了任何规则,执行重定向 if (desktopURL) { window.location.replace(desktopURL); } })();