-
-
Save t-rekttt/fefff0d6f06f70218dcf76cd06383ca5 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
var uid = require('CurrentUserInitialData').USER_ID; | |
var graphql = (data) => { | |
return new Promise(resolve => { | |
new AsyncRequest('/api/graphql').setData(data).setErrorHandler(res => resolve(JSON.parse(res.payload.response))).send() | |
}); | |
} | |
var getComments = (cursor) => { | |
return graphql({ variables: JSON.stringify({cursor, "count": 100,"category_key":"COMMENTSCLUSTER","entry_point":null,"timeline_visibility":null,"privacy":null,"year":null,"month":null,"scale":2.75}), doc_id: 2761528123917382 }).then(res => res.data.viewer.activity_log_actor.activity_log_stories); | |
} | |
var deleteComment = (id) => { | |
data = { | |
variables: JSON.stringify({"input":{"client_mutation_id":"1","story_id": id,"actor_id": uid,"story_location":"ACTIVITY_LOG","action":"REMOVE_COMMENT","category_key":"COMMENTSCLUSTER"}}), | |
doc_id: '1694179450603018' | |
} | |
return graphql(data); | |
} | |
(async() => { | |
let has_next = true; | |
let cursor = ''; | |
do { | |
let comments = await getComments(cursor); | |
let valid = comments.edges.filter(comment => comment.node.attached_story && comment.node.attached_story.actors[0].__typename == 'Page'); | |
console.log(valid.length); | |
for (item of valid) { | |
deleteComment(item.node.id).catch(err => {}); | |
} | |
has_next = comments.page_info.has_next_page; | |
cursor = comments.page_info.end_cursor; | |
} while (has_next); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment