移动版网站自动跳转到电脑版

自动将移动版网站重定向到对应的电脑版

// ==UserScript== 
// @name         移动版网站自动跳转到电脑版
// @namespace    http://tampermonkey.net/
// @version      1.2
// @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/*
// @match        *://waptieba.baidu.com/*
// @match        *://wapforum.baidu.com/*
// @grant        none
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const currentURL = window.location.href;
    let desktopURL = '';

    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}`;
    } 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 id = matches[2];
        desktopURL = `https://apps.qoo-app.com/app/${id}`;
    } else if (currentURL.includes('m.weibo.cn')) {
        desktopURL = currentURL.replace('m.weibo.cn', 'weibo.com');
    } 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`;
    } 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}`;
    } 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}`;
    } 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`;
    } else if (currentURL.includes('waptieba.baidu.com') || currentURL.includes('wapforum.baidu.com')) {
        desktopURL = currentURL.replace(/wap(?:tieba|forum)\.baidu\.com/, 'tieba.baidu.com');
    }

    if (desktopURL) {
        window.location.replace(desktopURL);
    }
})();