Automate Facebook Photo Untagging using JavaScript

After spending hours working on it, I want to create a JavaScript routine that can automatically untag me from photos on Facebook. My plan is to run this in the Firebug console so I can untangle myself from all Facebook photos, as there's no way to do this through the regular interface.

I'm looking for some advice to help me make progress on this challenge.

Although I have a few potential methods in mind, I haven't made much headway yet. One approach I've attempted involves using AJAX to create an HTML request directed at the remove_tag URL. Here's what the URL structure looks like:

/ajax/photo_tagging_ajax.php?pid=(PICTURE_ID)&id=(PICTURE_OWNER_ID)&subject=(SOMETHING)&name=(YOUR+NAME)&action=remove

Unfortunately, this method hasn't been successful yet. When I check the HTTP response in Firebug, it looks different from when I manually untag a picture. The request isn't even being sent as a POST.

Just to clarify, I also tried obtaining the "remove tag" anchor element by its ID and then attempting a document.location switcharoo, but that didn't work either. I was unable to trigger a click event on it.

I'm starting to wonder if my goal is feasible or if it's just a dream? (It's almost 4AM)

Answer №1

Shared by DCoder on Hacker News:

While utilizing Firebug, FireQuery, and jQuery with a no conflict alias as $jq within a photo page ():

  var loc = window.location.href.match(/pid=(\d+)&id=(\d+)/);

  var args = {
    pid: loc[1], // represents photo ID
    id: loc[2], // probably sender id or photo owner id - not thoroughly tested but successfully used my user ID to remove someone from my album's photo
    subject: loc[2], // specifies user ID for removal
    name: '', // not verified
    action: 'remove',
    __a: 1,
    fb_dtsg: $jq('input[name="fb_dtsg"]').val(),
    post_form_id: $jq('#post_form_id').val(),
    post_form_id_source: 'AsyncRequest'
  };

  $jq.post('/ajax/photo_tagging_ajax.php', args);

The UI does not reflect the changes made. The presence of fb_dtsg and post_form_id is crucial as they serve as anti-CSRF tokens. Further testing required to determine if they can be used repeatedly.

Answer №2

Just wanted to make sure you saw the updated version I shared on HN:

  var loc = window.location.href.split('?')[1].split('#')[0].split('&');
  var qs = {};
  $jq.each(loc, function(ix, el) {
   var m = el.split('='), k = m[0], v = m[1];
   qs[k] = v;
  });

  var args = {
    pid: qs.pid, // photo ID
    id: qs.id, // photo owner ID
    subject: Env.user, // user ID to remove
    name: '', // not checked
    action: 'remove',
    __a: 1,
    fb_dtsg: Env.fb_dtsg,
    post_form_id: Env.post_form_id,
    post_form_id_source: 'AsyncRequest'
  };

  $jq.post('/ajax/photo_tagging_ajax.php', args);

Answer №3

If you're looking for a Firefox plugin as an alternative to using the Firebug console, Chickenfoot could be just what you need. With Chickenfoot, you have the ability to create macros/scripts that automate repetitive tasks in your browser. This means you can code actions that mimic actual user interactions, such as clicking buttons and filling out forms. And don't forget, there's also a DOM interface available for traversing HTML elements. Check it out at .

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to partially update a function in Javascript without affecting specific lines of code

Straight to the point. I am working with a function inside a javascript class. For example: export default class gf{ iLoveThis(){ this.state.MakeMeWhole = true; callBoyfriend(); } } My goal is to override this method in another JS ...

Using TypeScript's reference function within an HTML document

It feels like ages since my early days of web development. Back when I first started coding, we would reference a script using a <script> tag: <html> <head> <script src="lealet.js"></script> <!-- I know the path isn´t c ...

I'm experiencing an issue with my dropdownlist not triggering the onchange event in AngularJS

I am a beginner in the world of AngularJS and I am trying to extract the values OnChange from a dropdown list. Here is the code that I have experimented with: <div> <select ng-controller="UserSelection as User" ng-model="User.UserSelected" n ...

Hide the body element's display style and show one child element with a block display style

Is it feasible to set the body's display to none while allowing one of its child elements to display as a block? I am struggling to articulate my question properly. Essentially, I am trying to hide the content of the body and only display a specific ...

Arranging an ng-repeat list in a dynamic order

I am currently working with AngularJS and focusing on reordering the ng-repeat list. The list represents online users who can receive messages at any time. When a user receives a message, I update the UI to display the most recent message beneath their nam ...

Javascript function that sets the opacity to 0

Hello everyone, I'm new to SO and seeking some guidance on improving my post! I have a function that sets the opacity of an element to 0 in order to clear it. While this works fine, it becomes burdensome when dealing with multiple elements that requi ...

Is there a way to integrate AJAX response Successful JSON data into a jQuery Datatable?

I am attempting to incorporate JSON data into a Datatable that I receive from an AJAX post Response. However, my current process is not functioning properly. Can anyone provide any suggestions or tips? Here is my AJAX code: $.ajax({ method: "POST", ...

Notifications will be displayed with Alertifyjs to the individual who activated them

Just diving into the world of nodejs and express framework, so I appreciate your patience as I navigate through this learning process. I've implemented the alertifyjs library to display notifications for different alerts on my site. However, I&apos ...

Retrieve the selected date from the date picker widget

Welcome to my custom datepicker! Here is the HTML code: <div class="field-birthday field-return" id="birthday-edit" style="display:none;"> <div class="birthdaypicker"></div> <input class="hidden" name="birthday" type="hidden" ...

What is the best way to rotate my geometry around the center in react-three-fiber?

Working on a personal side project where I'm utilizing react-three-fiber. The issue lies in the code below, which is responsible for rendering a text geometry with the text "Test". However, instead of rotating around its center, the Text Geometry appe ...

Encounter an error of "parsererror" while trying to download an XLSX file using $.ajax

When attempting to download a .xlsx file, my ajax request is successful, but the error callback throws a "parsererror - Invalid xml" message. The application sends a request for the file from a server that acts as a proxy to retrieve the file from another ...

Utilize JavaScript to implement CSS using an "if" statement

I am currently working on implementing iOS web app properties into my website. My goal is to create a <div> at the top of the page and apply specific CSS styles when a certain condition is met in a JavaScript script. Unfortunately, I am facing issue ...

Struggling with a persistent Jquery AJAX problem despite numerous attempts to resolve it

<table class="table table-striped"> <thead> <tr> <th>Choose</th> <th>>Location</th> <th>Topic</th> & ...

The function google.script.run encounters an error when dealing with file inputs

For the past two years, my Google Apps Script connected to a spreadsheet has been working flawlessly. I created an HTML form to upload CSV and Excel files for processing and data loading into the spreadsheet. However, since March 2020, file uploading has b ...

Ways to guide user after logging out

My Angular front end includes the following code in app.js to handle user logout: .when('/logout', { templateUrl: 'mysite/views/logout.html', resolve: { authenticated: ['djangoAuth', function(djangoAuth){ return ...

Tips for displaying a gallery of 5 images in a 2-row slider using bxslider

I've been attempting to create a unique image slider using bxslider. My goal is to have a 2-row slider with 5 images displayed in each row. However, I'm encountering difficulties when I try to integrate the HTML, CSS, and JavaScript code. Despit ...

What is the process for creating a unit test case for a button's onClick event with Jest?

In my attempt to unit test the onClick event of a button in a component, I encountered some challenges. Specifically, I am unsure how to properly test the onClick event when it triggers a function like Add(value). App.js function App(){ const[value,set ...

JavaScript code to toggle the navigation bar on mobile devices

I am experiencing an issue with a script that is not performing the desired task. I am looking for a script that can add the Class "active" to a ul element with the id "btnMob0". Currently, my script looks like this: <script type="text/javascript"> ...

Utilizing GroupBy in RxJs for an Observable of Objects数组

I am working with entries of type Observable<Event[]>, and they are structured as follows: [{ "_id": 1, "_title": "Test Event 1", "_startDate": "2019-05-29T07:20:00.000Z", "_endDate": "2019-05-29T08:00:00.000Z", "_isAllDay": false }, ...

Using Ajax script to transfer user information to a php file in order to refresh the modified row in a table

Recently, I created a table in PHP to display certain data. Here's how it looks: <?php echo '<table id="tableteste" class="table table-striped" width="100%">'; echo '<thead><tr>'; echo &apos ...