// ==UserScript== // @name 移动版网站自动跳转到电脑版 // @namespace http://tampermonkey.net/ // @version 1.1 // @description 自动将移动版网站重定向到对应的电脑版 // @author Claude // @match *://m.thepaper.cn/* // @match *://m.huaban.com/* // @match *://m.manhuagui.com/* // @match *://m.duitang.com/* // @match *://m-2.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/* // @match *://m.ximalaya.com/* // @match *://m.sohu.com/* // @match *://*.m.wikipedia.org/* // @match *://m.tianyancha.com/* // @match *://m.liepin.com/* // @match *://m.bookschina.com/* // @match *://m.dongman.la/* // @match *://m.92mh.com/* // @match *://m.dm5.com/* // @match *://m.twitch.tv/* // @match *://m.fx361.com/* // @match *://translate.ltaaa.cn/mobile/* // @match *://m.ltaaa.cn/* // @match *://m-apps.qoo-app.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', 'douban.com', 'zhipin.com', 'jiemian.com', 'ximalaya.com', 'sohu.com', 'tianyancha.com', 'liepin.com', 'bookschina.com', 'dongman.la', '92mh.com', 'dm5.com', 'twitch.tv', 'fx361.com' ]; // 处理简单替换的情况 for (const domain of simpleDomains) { if (currentURL.includes(`m.${domain}`)) { desktopURL = currentURL.replace(`m.${domain}`, domain); break; } } // 处理堆糖网不同的手机版本 if (currentURL.includes('m.duitang.com')) { desktopURL = currentURL.replace('m.duitang.com', 'duitang.com'); } else if (currentURL.includes('m-2.duitang.com')) { desktopURL = currentURL.replace('m-2.duitang.com', 'duitang.com'); } // 处理维基百科移动版 else if (currentURL.match(/([a-z]+)\.m\.wikipedia\.org/)) { const lang = currentURL.match(/([a-z]+)\.m\.wikipedia\.org/)[1]; desktopURL = currentURL.replace(`${lang}.m.wikipedia.org`, `${lang}.wikipedia.org`); } // 处理龙腾网 else if (currentURL.includes('translate.ltaaa.cn/mobile/article/')) { desktopURL = currentURL.replace('/mobile/article/', '/article/'); } else if (currentURL.match(/m\.ltaaa\.cn\/article\/(\d+)/)) { const id = currentURL.match(/m\.ltaaa\.cn\/article\/(\d+)/)[1]; desktopURL = `https://translate.ltaaa.cn/article/${id}`; } // 处理QooApp else if (currentURL.match(/m-apps\.qoo-app\.com\/([\w_]+)\/app\/(\d+)/)) { const matches = currentURL.match(/m-apps\.qoo-app\.com\/([\w_]+)\/app\/(\d+)/); const lang = matches[1]; const id = matches[2]; desktopURL = `https://apps.qoo-app.com/app/${id}`; } // 特殊情况处理 // m.weibo.cn -> weibo.com else 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); } })();