yichahucha / surge

Some useful scripts.
GNU General Public License v3.0
2.5k stars 482 forks source link

微博广告新url #115

Open ZhiyuanMa2017 opened 8 months ago

ZhiyuanMa2017 commented 8 months ago

https://api.weibo.cn/2/profile/container_timeline 在浏览用户主页时插入到该用户微博timeline中,json样式如下:

image

同样有"mblogtype" : 1的标记,所以可以使用已有的方法来处理。https://github.com/yichahucha/surge/blob/613f9b278aaf2386d81cf0aa06da75d7b7861d2f/wb_ad.js#L279-L285

Quantumult X里的用法: ^https://api.weibo.cn/2/profile/container_timeline url script-response-body https://raw.githubusercontent.com/ZhiyuanMa2017/Scripts/master/wb_ad_test_2.js

ZhiyuanMa2017 commented 8 months ago

这个和下面的两种同时存在,都需要

https://api.weibo.cn/2/searchall 搜索页面的广告 这个url现在对应的json样式如下:

image image

https://github.com/yichahucha/surge/blob/613f9b278aaf2386d81cf0aa06da75d7b7861d2f/wb_ad.js#L17 https://github.com/yichahucha/surge/blob/613f9b278aaf2386d81cf0aa06da75d7b7861d2f/wb_ad.js#L99-L108 所以这个判断方式不起作用了,需要直接判断obj.items[i].mblogtype Quantumult X里的用法: ^https://api.weibo.cn/2/searchall url script-response-body https://raw.githubusercontent.com/ZhiyuanMa2017/Scripts/master/wb_ad_test_2.js

ZhiyuanMa2017 commented 8 months ago

https://api.weibo.cn/2/statuses/extend 单条微博看评论的界面 这个url现在对应的json样式如下:

image

所以 https://github.com/yichahucha/surge/blob/613f9b278aaf2386d81cf0aa06da75d7b7861d2f/wb_ad.js#L7 https://github.com/yichahucha/surge/blob/613f9b278aaf2386d81cf0aa06da75d7b7861d2f/wb_ad.js#L54-L57 应该改成obj.head_cards就可以了 Quantumult X里的用法: ^https://api.weibo.cn/2/statuses/extend url script-response-body https://raw.githubusercontent.com/ZhiyuanMa2017/Scripts/master/wb_ad_test_4.js

ZhiyuanMa2017 commented 3 months ago

https://api.weibo.cn/2/statuses/repost_timeline 单条微博看转发的页面 对应json:

image image
if (obj.reposts && obj.reposts.length > 0) {
    let i = obj.reposts.length;
    while (i--) {
        if (obj.reposts[i].mblogtype && obj.reposts[i].mblogtype == 1) {
            obj.reposts.splice(i, 1);
        }
    }
}

Quantumult X里的用法: ^https://api.weibo.cn/2/statuses/repost_timeline url script-response-body https://raw.githubusercontent.com/ZhiyuanMa2017/Scripts/master/wb_ad_test_5.js

06/27/2024 update: 现在广告在 hot_reposts 中了,逻辑跟上述代码类似,我更新了 wb_ad_test_5.js,所以 Quantumult X 用法不变。

Jay17642121508 commented 3 months ago

这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

ZhiyuanMa2017 commented 3 months ago

https://api.weibo.cn/2/searchall 搜索页面的广告 对应json:

image

现在需要判断 obj.items[i].items[i].data, 可参考我的js: https://github.com/ZhiyuanMa2017/Scripts/blob/master/wb_ad_test_6.js 我对card_typetitle_extra_text 做判断,如果true就删掉最上层的items[i]

对于 https://api.weibo.cn/2/searchall ,这种样式的json和上面提到的json同时存在,有两种返回结果,现在我的做法:

if (obj.items && obj.items.length > 0) {
    let i = obj.items.length;
    while (i--) {
        if (obj.items[i].data && obj.items[i].data.mblogtype && obj.items[i].data.mblogtype == 1) {
            obj.items.splice(i, 1);
        } else if (isAd(obj.items[i])) {
            obj.items.splice(i, 1);
        }
    }
}

function isAd(item) {
    if (item.items) {
        let n = item.items.length
        for (let i = 0; i < n; i++) {
            let cur = item.items[i];
            if (cur.data && cur.data.card_type && cur.data.card_type == 22) {
                return true;
            }
            if (cur.data && cur.data.title_extra_text && cur.data.title_extra_text == "\u5e7f\u544a") {
                return true;
            }
        }
    }
    return false;
}

Quantumult X里的用法: ^https://api.weibo.cn/2/searchall url script-response-body https://raw.githubusercontent.com/ZhiyuanMa2017/Scripts/master/wb_ad_test_6.js