微博移动版(支持国际版)分享网页自动跳转PC版

微博手机版(支持国际版)分享网页自动跳转PC版! 原版来自https://greasyfork.org/scripts/395195(不支持国际版),

< Opinie na 微博移动版(支持国际版)分享网页自动跳转PC版

Ocena: Dobry - skrypt działa

§
Napisano: 19-07-2022

其实不需要直接访问https://weibo.com/ajax/side/cards/sideUser?*

建议:
在开头加上

// @grant        GM_xmlhttpRequest
// @connect      weibo.com

replaceShareUrl2CardUrl()函数改成

function replaceShareUrl2CardUrl()
{
    // 先用这个函数根据weibo id 找到对应的 用户 uid
    // let ret = window.location.href.match(/weibo_id=(\d+)/);
    // let weiboMobileId = window.location.href.substring(ret.index+ret[0].length);
    let weiboMobileId = window.location.href.match(/,(\d+)\.html/)[1];
    let weiboPcId = WeiboUtil.mid2url(weiboMobileId);
    let ajaxUrl = `https://weibo.com/ajax/side/cards/sideUser?id=${weiboMobileId}&idType=mid`
    // 用xhr访问
    GM_xmlhttpRequest({
        method: "GET",
        url: ajaxUrl,
        reponseType: 'json',
        onload: function(response) {
            if (response.status == 200){
                const weiboUid = response.responseText.match(/{"user":{"id":(\d+),/)[1];
                const pcUrl = `https://weibo.com/${weiboUid}/${weiboPcId}`;
                console.log(pcUrl)
                window.location.replace(pcUrl);
            }
        }
    });
}
keweilizheAutor
§
Napisano: 01-09-2022

其实不需要直接访问https://weibo.com/ajax/side/cards/sideUser?*

建议:

在开头加上

// @grant        GM_xmlhttpRequest
// @connect      weibo.com

replaceShareUrl2CardUrl()函数改成

function replaceShareUrl2CardUrl()
{
    // 先用这个函数根据weibo id 找到对应的 用户 uid
    // let ret = window.location.href.match(/weibo_id=(\d+)/);
    // let weiboMobileId = window.location.href.substring(ret.index+ret[0].length);
    let weiboMobileId = window.location.href.match(/,(\d+)\.html/)[1];
    let weiboPcId = WeiboUtil.mid2url(weiboMobileId);
    let ajaxUrl = `https://weibo.com/ajax/side/cards/sideUser?id=${weiboMobileId}&idType=mid`
    // 用xhr访问
    GM_xmlhttpRequest({
        method: "GET",
        url: ajaxUrl,
        reponseType: 'json',
        onload: function(response) {
            if (response.status == 200){
                const weiboUid = response.responseText.match(/{"user":{"id":(\d+),/)[1];
                const pcUrl = `https://weibo.com/${weiboUid}/${weiboPcId}`;
                console.log(pcUrl)
                window.location.replace(pcUrl);
            }
        }
    });
}

好的, 之前不太懂可以用GM request, 我改下
Thanks♪(・ω・)ノ大佬

Odpowiedz

Zaloguj się, by odpowiedzieć.