2024-09-30 05:25:43 -04:00
|
|
|
let tree = [], the, user = '08draven', gek = 0, spamTimeout = 0;
|
|
|
|
|
|
|
|
function getCookie(name) {
|
|
|
|
const value = `; ${document.cookie}`;
|
|
|
|
const parts = value.split(`; ${name}=`);
|
|
|
|
if (parts.length === 2) return parts.pop().split(';').shift();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function downloadUser(user) {
|
|
|
|
for (let i = 0; ; i++) {
|
2024-09-30 05:26:50 -04:00
|
|
|
let fetchReq = await fetch(`https://api.scratch.mit.edu/users/${user}/following/?limit=40&offset=${i * 40}`);
|
2024-09-30 05:25:43 -04:00
|
|
|
let fetchJson = await fetchReq.json();
|
|
|
|
if (fetchJson.length < 1) break;
|
|
|
|
tree = [...tree, ...fetchJson];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function unfollowUser(user) {
|
|
|
|
if (spamTimeout > 0) {
|
|
|
|
spamTimeout--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (the = tree[gek]) {
|
|
|
|
the = the.username;
|
|
|
|
e = await fetch(`https://scratch.mit.edu/site-api/users/followers/${the}/remove/?usernames=${user}`, {
|
|
|
|
"method": "PUT",
|
2024-09-30 05:31:55 -04:00
|
|
|
"body": "{}",
|
2024-09-30 05:33:54 -04:00
|
|
|
"credentials": "include",
|
2024-09-30 05:25:43 -04:00
|
|
|
"headers": {
|
2024-09-30 05:33:54 -04:00
|
|
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",
|
|
|
|
"Accept": "application/json, text/javascript, */*; q=0.01",
|
|
|
|
"Accept-Language": "en-US,en;q=0.5",
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
"x-csrftoken": getCookie('scratchcsrftoken'),
|
|
|
|
"X-Requested-With": "XMLHttpRequest",
|
|
|
|
"Sec-Fetch-Dest": "empty",
|
|
|
|
"Sec-Fetch-Mode": "cors",
|
|
|
|
"Sec-Fetch-Site": "same-origin",
|
|
|
|
"Priority": "u=0"
|
2024-09-30 05:25:43 -04:00
|
|
|
}
|
|
|
|
});
|
2024-09-30 05:31:55 -04:00
|
|
|
e = await e.text();
|
|
|
|
try {
|
|
|
|
e = JSON.parse(e);
|
|
|
|
} catch (err) {
|
|
|
|
e = {};
|
|
|
|
}
|
2024-09-30 05:25:43 -04:00
|
|
|
console.log(e);
|
2024-09-30 05:36:02 -04:00
|
|
|
if (!e[0].errors) {
|
2024-09-30 05:25:43 -04:00
|
|
|
gek++;
|
|
|
|
} else {
|
|
|
|
spamTimeout = 20;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log("end");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await downloadUser(user);
|
|
|
|
|
|
|
|
setInterval(function () {
|
|
|
|
unfollowUser(user)
|
|
|
|
}, 500)
|