Created
February 19, 2022 16:06
-
-
Save xmdhs/47102f6618581a4bc5ca75cd47a93b8a to your computer and use it in GitHub Desktop.
批量使用漫读券
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
let u = new URL(location.href); | |
let mc = u.pathname.match(/detail\/mc(\d+)/); | |
if (mc.length != 2) { | |
return | |
} | |
let mcid = mc[1]; | |
let r = await fetch("https://manga.bilibili.com/twirp/comic.v1.Comic/ComicDetail?device=pc&platform=web", { | |
"headers": { | |
"content-type": "application/json;charset=UTF-8", | |
}, | |
"referrer": "https://manga.bilibili.com/detail/mc" + mcid, | |
"body": JSON.stringify({ "comic_id": mcid }), | |
"method": "POST", | |
"mode": "cors", | |
"credentials": "include" | |
}); | |
let data = await r.json(); | |
if (data.code != 0) { | |
console.warn(data.msg); | |
return | |
} | |
data.data.ep_list.reverse() | |
for (const v of data.data.ep_list) { | |
if (!v.is_locked) { | |
continue | |
} | |
let r = await fetch("https://manga.bilibili.com/twirp/comic.v1.Comic/BuyEpisode?device=pc&platform=web", { | |
"headers": { | |
"content-type": "application/json;charset=UTF-8", | |
}, | |
"referrer": `https://manga.bilibili.com/mc${mcid}/${v.id}?from=manga_detail`, | |
"referrerPolicy": "strict-origin-when-cross-origin", | |
"body": JSON.stringify({ "buy_method": 2, "ep_id": v.id, "coupon_id": 6633775, "auto_pay_gold_status": 2 }), | |
"method": "POST", | |
}); | |
let data = await r.json(); | |
if (data.code != 0) { | |
console.warn(data.msg); | |
return | |
} | |
await new Promise(resolve => setTimeout(resolve, 1000)); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment