【通用-跳转】跳转电脑版

用于一些网站自动跳转电脑版

目前为 2023-08-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         【通用-跳转】跳转电脑版
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  用于一些网站自动跳转电脑版
// @author       You
// @match        *://finance.sina.cn/*
// @match        *://k.sina.cn/*
// @match        *://news.sina.cn/*
// @match        *://*.sina.cn/*

// @match        *://m.pipaw.com/*
// @match        *://m.kalvin.cn/*

// @match        *://wap.gamersky.com/*

// @icon         https://www.google.com/s2/favicons?sz=64&domain=gf.qytechs.cn
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

    var url = window.location.href;
    var domain = document.domain;

    var pcUrl = "";




    //新浪新闻
    ///html/head/script[5]/text()
    //document.querySelector("head > script:nth-child(30)")
    //https://news.sina.cn/2023-08-21/detail-imzhycna5519710.d.html
    //https://news.sina.com.cn/gov/xlxw/2023-08-21/doc-imzhycna5519710.shtml
    if (domain.includes('sina.cn')) {
        console.log('[跳转电脑版] 新浪');
        var scripts = document.querySelectorAll('script');
        let webURL = "";

        for (var i = 0; i < scripts.length; i++) {
            var script = scripts[i];

            var content = script.innerHTML;

            //var match = /"__webURL":"(.*?)"|"__webURL":'(.*?)'|'__webURL':'(.*?)'|'__webURL':"(.*?)"|__webURL:"(.*?)"|__webURL:'(.*?)'/.exec(content);
            var match = /"__webURL":"(.*?)"|'__webURL':'(.*?)'|__webURL:"(.*?)"|__webURL:'(.*?)'/.exec(content);

            if (match) {
                //var webURL = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
                webURL = match[1] || match[2] || match[3] || match[4];
                //console.log("__webURL 的内容为:" + webURL);
            }
        }


        pcUrl = webURL
            .replace(/\\/g, "");
        //return (pcUrl);

    }



    //琵琶网
    //http://m.pipaw.com/xin/520410.html
    //http://www.pipaw.com/xin/520410.html
    else if (domain.includes('m.pipaw.com')) {
        console.log('[跳转电脑版] 琵琶网');
        pcUrl = url
            .replace("m.pipaw.com","www.pipaw.com");

    }
    //咖绿茵手游站
    //https://m.kalvin.cn/gl/45240.html
    //https://www.kalvin.cn/gl/45240.html
    else if (domain.includes('m.kalvin.cn')) {
        console.log('[跳转电脑版] 咖绿茵手游站');
        let urlA = window.location.href;
        pcUrl = urlA
            .replace('m.kalvin.cn','www.kalvin.cn');

    }



    //游民星空
    //https://wap.gamersky.com/news/Content-1635505.html
    //https://www.gamersky.com/news/202308/1635505.shtml
    else if (domain.includes('wap.gamersky.com')) {
        console.log('[跳转电脑版] 游民星空');
        // 根据rel="canonical"查找link元素
        var canonicalLink = document.querySelector('head link[rel="canonical"]');

        // 获取href属性的值
        var hrefContent = canonicalLink.getAttribute('href');

        pcUrl = hrefContent;
    }









    console.log('[跳转电脑版] url:'+url);
    console.log('[跳转电脑版] pcUrl:'+pcUrl);

    function goPcUrl() {
        if (url !== pcUrl) {
            window.location.replace(pcUrl);
        }
    }
    setInterval(goPcUrl, 1000);



})();






//*************************************************************************************
//----------------------------------------匹配
//*************************************************************************************
/*
    //新浪科技
    //https://finance.sina.cn/tech/2020-12-01/detail-iiznctke4237221.d.html
    //https://tech.sina.com.cn/roll/2020-12-01/doc-iiznctke4237221.shtml
    if (domain.includes('finance.sina.cn') && url.match(/finance.sina.cn\/tech\/\d{4}-\d{2}-\d{2}\/detail-[a-zA-Z]{8}\d{7}\.d\.html/)) {
        console.log('[跳转电脑版] 新浪科技');
        pcUrl = url
            .replace("finance.sina.cn","tech.sina.com.cn")
            .replace("/tech/","/roll/")
            .replace("/detail-","/doc-")
            .replace(".d.html",".shtml");
        window.location.replace(pcUrl);

    }
    //新浪看点
    //https://k.sina.cn/article_7301049552_1b32d2cd00200124dx.html?from=history
    //https://k.sina.com.cn/article_7301049552_1b32d2cd00200124dx.html
    if (domain.includes('k.sina.cn') && url.match(/k.sina.cn\/article_\d{10}_[0-9a-zA-Z]{17,18}\.html/)) {
        console.log('[跳转电脑版] 新浪科技');
        pcUrl = url
            .replace("k.sina.cn","k.sina.com.cn");
        window.location.replace(pcUrl);

    }
    */

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址