Advertisement
Guest User

Delete Pending Post (Facebook Group)

a guest
Nov 14th, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. !((groupId, dtsg) => {
  2.     let glob = {
  3.         dtsg: require("DTSGInitialData").token || document.querySelector('[name="fb_dtsg"]').value,
  4.         posts: [],
  5.         del: function() {
  6.             this.posts.reduce((cp, post, index, arr) => {
  7.                 return cp.then((e) => {
  8.                     if (e) {
  9.                         let f = new FormData();
  10.                         f.append("group_id", groupId);
  11.                         f.append("post_id", post);
  12.                         f.append("pending", 1);
  13.                         f.append("story_dom_id", `mall_post_${post}`);
  14.                         f.append("fb_dtsg", this.dtsg);
  15.                         f.append("nctr[_mod]", "pagelet_pending_queue");
  16.                         f.append("confirmed", 1);
  17.                         return fetch("https://www.facebook.com/ajax/groups/mall/delete/?dpr=1", {method: "POST", credentials: "include", body: f}).then((e) => (String(e.status).match(/^2/g)) ? (console.log(`Deleted Post: ${post} || ${index + 1}/${arr.length}`), true) : (console.log(`Failed To Delete Post: ${post + 1} || ${index}/${arr.length}`), false));
  18.                     }
  19.                 });
  20.             }, Promise.resolve(true)).then((e) => {console.log("Done!");});
  21.         },
  22.         getPost: function(groupId, cur) {
  23.             fetch(`https://www.facebook.com/ajax/pagelet/generic.php/PendingQueuePagelet?dpr=1&data=%7B%22group_id%22%3A${groupId}%2C%22cursor%22%3A%22${cur}%22%2C%22sort_option%22%3A%22request_time%22%7D&__a=1`).then((res) => res.text()).then((e) => {
  24.                 let cur = e.match(/(?<=cursor":").*(?=","sort)/g), post = e.match(/(?<=&post_id=)\d+(?=")/g);
  25.                 this.posts = [...this.posts, ...post];
  26.                 console.log(`Added Post ID To DB: ${String(post)}`);
  27.                 (cur) ? this.getPost(groupId, cur[0]) : this.del();
  28.             });
  29.         }
  30.     };
  31.     glob.getPost(groupId);
  32. })(document.documentElement.outerHTML.match(/(?<=group_id=)\d+/g)[0]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement