Skip to content

Instantly share code, notes, and snippets.

@Konard
Last active October 11, 2021 18:14
Show Gist options
  • Save Konard/9d5cc07b788edfa980dc0cd3a1d5f2fd to your computer and use it in GitHub Desktop.
Save Konard/9d5cc07b788edfa980dc0cd3a1d5f2fd to your computer and use it in GitHub Desktop.
VK automation scripts (written in VK script). These scripts should be set up via https://vk.com/apps?act=manage to be usable. To execute via curl you will need to get token: https://oauth.vk.com/authorize?client_id=0&scope=friends&redirect_uri=https://oauth.vk.com/blank.html&display=page&response_type=token&revoke=1 (replace 0 near client_id wit…
#!/bin/bash
ACCESS_TOKEN=`cat access-token`
while :
do
curl "https://api.vk.com/method/execute.acceptAllFriendRequests?access_token=${ACCESS_TOKEN}&v=5.131"
printf "\n"
sleep 2400
done
#!/bin/bash
ACCESS_TOKEN=`cat access-token`
curl "https://api.vk.com/method/execute.acceptBestSuggestion?access_token=${ACCESS_TOKEN}&v=5.131&offset=$1"
printf "\n"
var requests = API.friends.getRequests().items;
var i = 0;
while(i < requests.length)
{
API.friends.add({ user_id: requests[i] });
i = i + 1;
}
return requests;
var count = 50;
var currentUserId = API.users.get()[0].id;
var suggestions = API.friends.getSuggestions({ filter: "mutual", fields: "online,last_seen", count: count, offset: count * Args.offset }).items;
var maxItem = [0, 0];
var i = 0;
while(i < suggestions.length)
{
var suggestion = suggestions[i];
if (suggestion.online) {
var mutualFriendsCount = API.friends.getMutual({ source_uid: currentUserId, target_uid: suggestion.id }).length;
if (mutualFriendsCount > maxItem[1]) {
maxItem = [suggestion.id, mutualFriendsCount];
}
}
i = i + 1;
}
if (maxItem[0] > 0) {
API.friends.add({ user_id: maxItem[0] });
}
return maxItem;
#!/bin/bash
ACCESS_TOKEN=`cat access-token`
while :
do
curl "https://api.vk.com/method/execute.deleteFirstDeactivatedFriend?access_token=${ACCESS_TOKEN}&v=5.131"
printf "\n"
sleep 2400
done
#!/bin/bash
ACCESS_TOKEN=`cat access-token`
curl "https://api.vk.com/method/execute.deleteInactiveFriends?access_token=${ACCESS_TOKEN}&v=5.131&offset=$1"
printf "\n"
#!/bin/bash
ACCESS_TOKEN=`cat access-token`
curl "https://api.vk.com/method/execute.deleteOutFriendRequests?access_token=${ACCESS_TOKEN}&v=5.131"
printf "\n"
var currentUserId = API.users.get()[0].id;
var friendsOffset = 0;
var step = 5000;
var operations = 2;
var deletedFriendsIds = [];
while(friendsOffset < 10000)
{
var friends = API.friends.get({ user_id: currentUserId, offset: friendsOffset, fields: "photo_50" });
var photos = [email protected]_50;
var deactivatedIndex = photos.indexOf("https://vk.com/images/deactivated_50.png");
while ((deactivatedIndex > 0) && (deletedFriendsIds.length < operations))
{
var userIdToDelete = friends.items[deactivatedIndex].id;
deletedFriendsIds.push(userIdToDelete);
API.friends.delete({ user_id: userIdToDelete });
if(deletedFriendsIds.length >= operations)
{
return "deleted friends: " + deletedFriendsIds;
}
friends.items = friends.items.slice(deactivatedIndex);
photos = photos.slice(deactivatedIndex);
deactivatedIndex = photos.indexOf("https://vk.com/images/deactivated_50.png");
}
friendsOffset = friendsOffset + step;
}
if(deletedFriendsIds.length <= 0)
{
return "no deactivated friends";
}
else
{
return "deleted friends: " + deletedFriendsIds;
}
var currentUserId = API.users.get()[0].id;
var offsets = [
0000,0250,0500,0750,
1000,1250,1500,1750, // 8
2000,2250,2500,2750,
3000,3250,3500,3750, // 16
4000,4250,4500,4750,
5000,5250,5500,5750, // 24
6000,6250,6500,6750,
7000,7250,7500,7750, // 32
8000,8250,8500,8750,
9000,9250,9500,9750 // 36
];
var friendsOffset = offsets[35-Args.offset];
var step = 250;
var deletedFriendsIds = [];
var timebarier = API.utils.getServerTime() - 604800; // 7 days less
var friends = API.friends.get({ user_id: currentUserId, count: step, offset: friendsOffset, fields: "last_seen" }).items;
var i = 0;
while(i < friends.length)
{
var last_seen_time = friends[i].last_seen.time;
if (last_seen_time != null && (last_seen_time > 0) && (last_seen_time <= timebarier) && (friends[i].id > 50000000)) {
API.friends.delete({ user_id: friends[i].id });
deletedFriendsIds.push(friends[i].id);
}
i = i + 1;
}
return deletedFriendsIds;
var requests = API.friends.getRequests({ out: 1 }).items;
var i = 0;
while(i < requests.length)
{
API.friends.delete({ user_id: requests[i] });
i = i + 1;
}
return requests;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment