Skip to content

Instantly share code, notes, and snippets.

@justbispo
Forked from HyperCrowd/CutOffFacebook.md
Created June 23, 2024 02:26
Show Gist options
  • Save justbispo/f7926166e4a2088a5b5024996b142d9e to your computer and use it in GitHub Desktop.
Save justbispo/f7926166e4a2088a5b5024996b142d9e to your computer and use it in GitHub Desktop.

Crippling Facebook

Facebook works with advertisers to target you. These instructions are one of the many ways to begin crippling that relationship. When AI targeting is crippled, your psychosecurity improves :)

  1. On your desktop machine, goto https://accountscenter.facebook.com/ads/audience_based_advertising
  2. Maximize the browser window
  3. Press F12 and click on the Console tab
  4. Select the code below, copy it, paste it upon the Console line (The area next to the > character in the Console window), and press enter:
(async function() {
  const wait = async (watcher, timeout = 10000, interval = 100) => {
    const startTime = Date.now()

    return new Promise((resolve, reject) => {
      const checkForElement = () => {
        const elements = watcher()

        if (elements.length > 0) {
          clearInterval(intervalId)
          resolve(elements);
        } else if (Date.now() - startTime > timeout) {
          clearInterval(intervalId)
          reject(new Error(`Timeout: Elements not found`))
        }
      }

      const intervalId = setInterval(checkForElement, interval)

      checkForElement()
    })
  }

  const delay = () => new Promise(resolve => setTimeout(resolve, 3000))
  const getElementsByAriaLabel = (label) => document.querySelectorAll(`[aria-label="${label}"]`)
  const getElementsByRoleAndWidth = (role, width) => 
      Array.from(document.querySelectorAll(`[role="${role}"]`)).filter(el => el.clientWidth === width)
  const getElementsByText = (text) => Array.from(document.querySelectorAll('*')).filter(el => 
      Array.from(el.childNodes).some(node => node.nodeType === Node.TEXT_NODE && node.textContent.includes(text))
  )

  const ads = getElementsByRoleAndWidth('listitem', 508)

  for (const ad of ads) {
      console.log(ad.childNodes[0].textContent)
      ad.childNodes[0].click()
      await delay()

      const a = await wait(() => getElementsByText('They uploaded or used a list to reach you.'))
      a[0].click()
      await delay()

      const b = await wait(() => getElementsByText('Don\'t allow'))
      b[1].click()
      await delay()

      const c = await wait(() => getElementsByText('Don\'t allow'))
      c[0].click()
      await delay()

      const d = await wait(() => getElementsByAriaLabel('Back'))
      d[2].click()
      await delay()

      const e = await wait(() => getElementsByAriaLabel('Back'))
      e[2].click()
      await delay()
  }
})()
  1. Watch as your slowly unsubscribe from all advertisers
  2. Don't click or interact with the browser at all while this is going on. Go do laundry or something.
  3. Enjoy cutting off advertisers that hate you :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment