55 líneas
2.2 KiB
JavaScript
55 líneas
2.2 KiB
JavaScript
'use strict'
|
|
const requestsync = require('sync-request')
|
|
|
|
let body = requestsync('GET', 'https://social.hatthieves.es/api/v1/instance/peers'),
|
|
urls = JSON.parse(body.getBody())
|
|
|
|
//for (let url of urls) {
|
|
let url = 'social.hatthieves.es',
|
|
count = 100
|
|
try {
|
|
let actors,
|
|
followed = []
|
|
do {
|
|
let id = actors && actors.length > 0 ? actors[actors.length - 1].id : '',
|
|
// body = requestsync('GET', 'https://ale:pleroma.@' + url + '/api/v1/accounts/9lM7CeFGQNLWp38fgW/following?max_id=' + id + '&limit=' + count)
|
|
body = requestsync('GET', 'https://ale:pleroma.@' + url + '/api/v1/accounts/9lM7CeFGQNLWp38fgW/followers?max_id=' + id + '&limit=' + count)
|
|
try {
|
|
actors = JSON.parse(body.getBody())
|
|
if (actors && actors.length > 0) {
|
|
for (let a of actors) {
|
|
if (a && a.id) {
|
|
followed.push(a)
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
console.log('Loading users: ' + followed.length)
|
|
} while (actors && actors.length >= count)
|
|
/* actors = []
|
|
do {
|
|
let id = actors && actors.length > 0 ? actors[actors.length - 1].id : '',
|
|
body = requestsync('GET', 'https://' + url + '/api/statuses/networkpublic_timeline?max_id=' + id + '&only_media=false&count=20&with_muted=true')
|
|
try {
|
|
actors = JSON.parse(body.getBody())*/
|
|
if (followed && followed.length > 0) {
|
|
for (let a of followed) {
|
|
if (a && a.id) {
|
|
requestsync('POST', 'https://ale:pleroma.@social.hatthieves.es/api/v1/accounts/' + a.id + '/follow')
|
|
console.log('Re-following: ' + a.display_name)
|
|
}
|
|
}
|
|
}/*
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
console.log(url + ' following: ' + followed.length)
|
|
} while (actors && actors.length >= 20)*/
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
//}
|
|
|