Created
November 27, 2018 18:51
-
-
Save monokaijs/cc4796c95ef1b6550240b5d6e73a6b4b to your computer and use it in GitHub Desktop.
stopIt - Block Group User
This file contains hidden or 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
/* | |
Modified from: https://github.com/facoder2k2/userScripts/blob/master/facebookGroupMouthLocker.js | |
-> removed prompt | |
-> removed annoy names | |
*/ | |
!(() => { | |
var random_array = (array) => { | |
return array[Math.round(Math.random()*(array.length-1))]; | |
} | |
function stopIt(btn) { | |
let cmtId = btn.getAttribute("cmtid"), dtsg = require("DTSGInitialData").token || document.querySelector('[name="fb_dtsg"]').value, | |
f1 = new FormData(), f2 = new FormData(), groupId = document.documentElement.outerHTML.match(/(?<=groupID":")\d+(?=")/g)[0], post = btn.getAttribute("postid"), | |
template = 'Bạn đã bị cấm tương tác', user = btn.getAttribute("user"); | |
f1.append("fb_dtsg", dtsg); | |
f1.append("group_id", groupId); | |
f1.append("mute_duration", "seven_days"); | |
f1.append("shoud_reload", false); | |
f1.append("source", "profile_browser"); | |
f1.append("user_id", user); | |
f2.append("attached_sticker_fbid", 114314779163130); | |
f2.append("client_id", "1489983090155:3363757627"); | |
f2.append("comment_text", template); | |
f2.append("fb_dtsg", dtsg); | |
f2.append("ft_ent_identifier", post); | |
f2.append("parent_comment_id", `${post}_${cmtId}`); | |
f2.append("reply_fbid", cmtId); | |
f2.append("session_id", "84d81e4"); | |
f2.append("source", 2); | |
fetch("https://www.facebook.com/groups/mutemember/?dpr=1", {method: "POST", credentials: "include", body: f1}) | |
.then((e) => (String(e.status).match(/^2/g)) ? true : false) | |
.then((e) => (e) ? fetch("https://www.facebook.com/ufi/add/comment/?dpr=1", {method: "POST", credentials: "include", body: f2}) : alert(`Khoá mõm bất thành: ${user}`)); | |
} | |
let script = document.createElement("script"); | |
script.innerHTML = String(stopIt); | |
document.head.appendChild(script); | |
document.querySelectorAll("div[role='article'][aria-label='Comment']").forEach((cmt) => { | |
let cmtId = cmt.querySelector("a[href*='comment_id']"), | |
user = cmt.querySelector("a[data-hovercard*='/ajax/hovercard/hovercard.php?id=']"), | |
user2 = cmt.querySelector("a[data-hovercard*='/ajax/hovercard/user.php?id=']"), | |
a = document.createElement("a"); | |
if (cmtId) { | |
a.innerHTML = "  Cấm tương tác"; | |
a.href = "#"; | |
a.setAttribute("cmtid", cmtId.getAttribute("href").match(/(?<=comment_id=)\d+/g)[0]); | |
a.setAttribute("onclick", "stopIt(this);"); | |
if (user) { | |
a.setAttribute("user", user.getAttribute("data-hovercard").match(/(?<=id=)\d+/g)[0]); | |
a.setAttribute("postid", cmt.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector("a[href*='/groups/'][target]").href.match(/\d+(?=\/$)/g)[0]); | |
cmt.querySelector(".UFICommentActions").appendChild(a); | |
} else if (user2) { | |
a.setAttribute("user", user2.getAttribute("data-hovercard").match(/\d+$/g)[0]); | |
a.setAttribute("postid", cmt.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector("a[href*='/groups/'][target]").href.match(/\d+(?=\/$)/g)[0]); | |
cmt.lastElementChild.lastElementChild.lastElementChild.appendChild(a); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment