Population: Infinite Week 2

Assignment: Identify a surveillance apparatus that tracks your activity (online or offline). Design a set of instructions for a procedure that confuses it, and perform those instructions.

I decided to “confuse” Facebook. Facebook constantly tracks your online activity to alter your newsfeed, ads, videos and anything that you see based on your activity. This is obviously to personalize your experience, but at times it can feel a bit too personal or exact. In order to confuse Facebook, I thought that one could basically watch videos that were unrelated, like random pages, or join various groups. During class, we were taught how to use puppeteer and I wanted to utilize that in order to complete this assignment. So instead of thoroughly confusing Facebook, this was more of a puppeteer exploration for me.

Basically I created a Facebook “alter ego” named Garin Campbell. In order to confuse Facebook, I would suggest looking up a random video, watching it for at least 10 seconds and then proceeding to watch a random “up next” video and continuing that for a long or as little as you’d like. Since Garin Campbell was just created, their suggested videos already change after watching one video. Even when I watch one video that’s different than my normal viewing activity, I start to see changes in my suggested videos because of one video that I watched. Then I’d proceed to start searching for and liking as many or as little pages as you’d like. Then doing the same for joining groups. If you have enough randomness in your searches and profile, I believe that throws Facebook off of its tracks at least a little bit.

For puppeteer, I was able to search and watch a random video (random as in a random word from an array of words). Then I searched for a random (from a list of words) page and liked the second page that came up. After a page is liked, I search for a random group and join the 5th group that comes up. I ran this multiple times and sometimes it would work and other times it didn’t work. Some things are difficult and time consuming to perform with puppeteer because the selectors that Facebook uses for every element changes and since I just started using selectors on facebook, I was unable to figure a way around this. Most videos take a very long time to load, so even the 15 second wait period was not long enough to start a video. I also had difficulty randomizing more choices because each selector was different and in no recognizable way that I could easily complete a randomization.

Below is the code I used to perform my instructions and a video of some of my puppeteer code working, kind of.

const puppeteer = require('puppeteer');

function randomElementFromArray(array) {
  const randomIndex = Math.floor(Math.random() * array.length);

  return array[randomIndex];
}

async function loginToFacebook(page, email, password) {
  await page.goto('https://www.facebook.com');

  // enter email address and password
  await page.type('input[type="email"]', 'campbellgarin');
  await page.type('input[type="password"]', '___');

  await page.click('input[type="submit"]');

  // give page time to load
  await page.waitFor(5000);

  // click on page to get rid of message
  await page.mouse.click(1000, 1000);
}

async function program() {
  // launch puppeteer
  const browser = await puppeteer.launch({
    headless: false,
    slowMo: 20
  });

  const context = await browser.createIncognitoBrowserContext(); //incognito mode

  // create a page
  const page = await context.newPage(); //incognito

  await page.setViewport({
    width: 1280,
    height: 720
  });

  const email = "campbellgarin";
  const password = "sujfeJ-fitzo6-morwik";

  await loginToFacebook(page, email, password);

  await page.waitFor(3000); //waits before doing things in milliseconds (may not work)

  // await page.waitFor(#navItem_2392950137 > a > div);
  await page.click('#navItem_2392950137 > a > div'); //clicking on textarea

  await page.waitFor(3000);

  // await page.click('input._1frb'); //searchBar
  await page.click('#u_fetchstream_2_2 > span > span > input')
  //
  const searchs = ["obnoxious", "tense", "secret", "trip", "womanly", "haunt", "futuristic", "lush", "jail", "outstanding", "news", "animals", "food", "guns", "pickle", "electronics", "jam", "makeup", "exercise", "diy", "plants", "south", "taxes", "travel", "alcohol", "celebrities", "meme", "funny", "games", "great", "regret", "wide-eyed", "tart", "shaky"];
  const randSearches = randomElementFromArray(searchs);
  console.log(randSearches);

  await page.keyboard.type(randSearches);
  await page.keyboard.press('Enter');
  await page.waitFor(3000);

  await page.click('#u_fetchstream_3_4 > div > a'); //first video

  await page.waitFor(15000);

  // await page.click('#u_2e_9 > div > span'); // trying to play the "up next" videos


  // await page.mouse.click(2000, 2000);

  // await page.waitFor(10000);
  //
  await page.click('input._1frb'); //search bar

  const randSearches1 = randomElementFromArray(searchs);
  console.log(randSearches1);

  await page.keyboard.type(randSearches1);
  await page.keyboard.press('Enter');

  await page.waitFor(3000);

  await page.click('#u_fetchstream_4_1 > div > div > div > ul > li:nth-child(6) > a > div > div._4xjz') //pages

  await page.waitFor(1000);
  await page.click('#u_ps_fetchstream_5_3_b'); //2nd page

  // await page.waitFor(1000);
  // await page.click('#u_fetchstream_7_7 > div > div > div:nth-child(1) > div > span > button') //like the page htat youre on

  await page.waitFor(2000);

  await page.click('input._1frb'); //search bar

  const randSearches2 = randomElementFromArray(searchs);
  console.log(randSearches2);

  await page.keyboard.type(randSearches2);
  await page.keyboard.press('Enter');

  await page.waitFor(3000);

  await page.click('#u_fetchstream_8_1 > div > div > div > ul > li:nth-child(8) > a > div > div._4xjz') //groups

  await page.click('#u_ps_fetchstream_9_3_3') //5th groups
  // await page.waitFor(3000);
  // await page.click('#joinButton')

  //

  // await page.click('#js_4n');

  // await page.watiFor(2000);

  // await page.click('#u_fetchstream_3_8 > div > div > div:nth-child(1) > div > span > button');
  // await page.keyboard.type('\n');

}
program();