Created
November 26, 2023 15:00
-
-
Save rebane2001/1212eb1470cbaf24c8245bc804755f19 to your computer and use it in GitHub Desktop.
Facebook - Set everything to "Only me" (private)
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
/* | |
This script sets every post on your Facebook profile to "Only me". | |
It's very hastily thrown together and will most certainly break in the future, but it should at least provide a starting point for anyone else who wants to do this. | |
Make sure to change your name below before running. | |
Run by just pasting into the JS console. | |
*/ | |
const targetName = "Your Name"; | |
const actionDelay = 1500; | |
const scrollDelay = 500; | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function setEverythingToOnlyMe() { | |
while (true) { | |
const privacyButtons = Array.from(document.querySelectorAll(".xzpqnlu.x179tack.x10l6tqk")).filter(e=>e.innerText.includes("Shared with") && e.innerText !== "Shared with Only me"); | |
for (const privacyButton of privacyButtons) { | |
const postHeadRoot = privacyButton.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; | |
if ((postHeadRoot.querySelector("strong>span") || postHeadRoot.querySelector("a>span")).innerText == targetName){ | |
privacyButton.parentNode.querySelector("img").click(); | |
await sleep(actionDelay); | |
Array.from(document.querySelectorAll(".xu06os2.x1ok221b")).filter(e=>e.innerText=="Only me")[0].click(); | |
await sleep(actionDelay); | |
(document.querySelector('[aria-label="Save"]') || document.querySelector('[aria-label="Done"]')).click(); | |
await sleep(scrollDelay); | |
} | |
} | |
scrollTo(0, 1e10); | |
await sleep(actionDelay); | |
} | |
} | |
setEverythingToOnlyMe(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment