Hacker News new | ask | show | jobs
by DCoder 5881 days ago
Sorry, I hadn't tested that enough. Here's a revised version that works better. Tested and removed my tag from another account's photo correctly. Unfortunately the CSRF tokens are not updated in the response, so you cannot run multiple requests without retrieving new tokens (opening another page should be enough).

  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);
It seems to me that now it should be easy to adapt this to work on the "photos of me" page if you don't mind reloading it after each removal - $jq('a.UIPhotoGrid_PhotoLink:first'); should find the first link to a photo, and you can tokenize it instead of window.location.href on the first line.