ourfor / blog

利用GitHub的Issues记录
https://github.com/ourfor/blog/issues
1 stars 0 forks source link

Surge脚本 #88

Open ourfor opened 1 year ago

ourfor commented 1 year ago
[Script]
EmbyPremiere = type=http-response,script-path=https://raw.githubusercontent.com/rartv/SurgeScript/main/EmbyPremiere/EmbyPremiere.js,pattern=^https?:\/\/mb3admin.com\/admin\/service\/registration\/validateDevice,max-size=131072,requires-body=true,timeout=10,enable=true

[MITM]
hostname = mb3admin.com

例子

if ($request.url.indexOf('mb3admin.com/admin/service/registration/validateDevice') != -1) {
    if($response.status!=200){
        $notification.post("Emby Premiere 已激活", "", "");
        $done({status: 200, headers: $response.headers, body: '{"cacheExpirationDays":999,"resultCode":"GOOD","message":"Device Valid"}' })
    }else{
        $done({})
    }
}else{
    $done({})
}
ourfor commented 1 year ago

再比如修改ChatGPT聊天网页显示的用户名、邮件、头像等

if ($request.url.indexOf('chat.openai.com/api/auth/session') != -1) {
    if($response.status == 200){
        $notification.post("ChatGPT 个性化", "", "");
        const data = JSON.parse($response.body);
        data.user.name = "风暴降生龙之母";
        data.user.email = "god@mail.com"
        $done({status: 200, headers: $response.headers, body: JSON.stringify(data) })
    }else{
        $done({})
    }
}else{
    $done({})
}
image image

效果如下

image
ourfor commented 1 year ago

当然,也可以借助油猴脚本重写浏览器的fetch,每种方法有它的应用场景,你甚至可以通过伪站来实现,做到无感知