Skip to content

Instantly share code, notes, and snippets.

@abersheeran
Created May 24, 2024 08:02
Show Gist options
  • Save abersheeran/4838fe4287f7ba4dda64165fc8ffd15e to your computer and use it in GitHub Desktop.
Save abersheeran/4838fe4287f7ba4dda64165fc8ffd15e to your computer and use it in GitHub Desktop.
领取 bilibili 大会员权益
function getCSRFToken() {
let bilijct = "";
document.cookie
.split(";")
.filter((cookie) => cookie.includes("bili_jct"))
.forEach((cookie) => {
const [name, value] = cookie.split("=");
bilijct = value;
});
return bilijct;
}
let api_url = "https://api.bilibili.com/x/vip/privilege/receive";
let form = new FormData();
form = new FormData();
form.append("type", "1");
form.append("platform", "web");
form.append("csrf", getCSRFToken());
fetch(api_url, {
method: "POST",
body: form,
credentials: "include",
})
.then((response) => response.json())
.then((data) => {
console.log(data);
});
form = new FormData();
form.append("type", "3");
form.append("platform", "web");
form.append("csrf", getCSRFToken());
fetch(api_url, {
method: "POST",
body: form,
credentials: "include",
})
.then((response) => response.json())
.then((data) => {
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment