使用 Javascript 以编程方式取消 FB 照片标签

发布于 2024-09-02 14:34:55 字数 717 浏览 8 评论 0原文

在过去的一个小时里,我一直在研究这个问题:我想编写一个 Javscript 例程,以编程方式从 Facebook 上的照片中取消自己的标签。一旦它起作用,我将在 Firebug 控制台中运行它,并从所有 Facebook 照片中取消自己的标签(无法通过 GUI 执行此操作)。

我想看看你们是否能给我一些建议来帮助我踏上旅程。

我心里有一些方法,但还没有走得太远。我尝试了 AJAX 方法,创建一个新的 HTML 请求并将其指向 remove_tag URL,如下所示:

/ajax/photo_tagging_ajax.php?pid=(PICTURE_ID)&id=(PICTURE_OWNER_ID)&subject=(SOMETHING) &name=(您的+NAME)&action=删除

毫不奇怪,这还不起作用。我一直在 Firebug 中检查 HTTP 响应,它与我实际取消标记图片时的响应有很大不同。它甚至不发送 POST 请求。

为了澄清一下,我还尝试在“删除标签”锚点上执行 getElementById,然后执行 document.location switcharoo,但这不起作用。我也无法对其执行 .click() 。

这可能吗?还是我在做梦? (已经快凌晨 4 点了)

I've spent the past hour hacking away at this: I want to write a Javscript routine to programatically untag myself from photos on Facebook. Once it works, I'll run it in the Firebug console and untag myself from all Facebook photos (there's no way to do this through the GUI).

I wanted to see if you guys had some advice to get me on my journey.

I have a few methods in mind but haven't come too far along quite yet. I've tried an AJAX approach by creating a new HTML request and pointing it to the remove_tag URL, which looks something like this:

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

Not surprisingly, this doesn't work (yet). I've been checking the HTTP response in Firebug and it's quite different than the one when I actually untag a picture. It's not even sending a POST request.

Just to clarify, I've also tried doing a getElementById on the "remove tag" anchor, and then doing a document.location switcharoo, but that doesn't work. I also can't do a .click() on it.

Will this even be possible or am I dreaming? (it's almost 4AM)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风吹雨成花 2024-09-09 14:34:55

来自 DCoder,通过 黑客新闻

使用 Firebug、FireQuery、jQuery 与 $jq 没有冲突,从照片页面 (http://www.facebook.com/photo.php?pid=xxx&id=y) :

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

  var args = {
    pid: loc[1], // photo ID
    id: loc[2], // request sender id? photo owner id? not sure, haven't tested, but my user ID worked when trying to remove someone from a photo in my album
    subject: loc[2], // user ID to remove
    name: '', // not checked
    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);

它不会更新 UI。 fb_dtsg 和 post_form_id 是必需的,并且似乎是反 CSRF 令牌。还没有进行足够的实验,不知道它们是否可以多次重复使用。

From DCoder, via Hacker News:

Using Firebug, FireQuery, jQuery no conflict as $jq, from inside a photo page (http://www.facebook.com/photo.php?pid=xxx&id=y) :

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

  var args = {
    pid: loc[1], // photo ID
    id: loc[2], // request sender id? photo owner id? not sure, haven't tested, but my user ID worked when trying to remove someone from a photo in my album
    subject: loc[2], // user ID to remove
    name: '', // not checked
    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);

It doesn't update the UI. The fb_dtsg and post_form_id are required and seem to be anti-CSRF tokens. Haven't experimented enough to know if they can be reused multiple times.

凝望流年 2024-09-09 14:34:55

因为我不确定您是否在 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);

Since I'm not sure if you picked up my updated version at 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);
可可 2024-09-09 14:34:55

鸡足 http://groups.csail.mit.edu/uid/chickenfoot/是一个 Firefox 插件,可能是使用 Firebug 控制台的替代方案:您可以编写宏/脚本来自动执行浏览器中的重复任务。您编码的操作与您实际单击、填充表单或您自己执行的任何操作没有什么不同。据我所知,有一个用于遍历 html 等的 DOM 接口。

Chickenfoot http://groups.csail.mit.edu/uid/chickenfoot/ is a Firefox plugin that might be an alternative to using the Firebug console: you can write macros/scripts to automate repetitive tasks in your browser. The actions you code for are no different to you actually clicking, populating forms or whatever yourself. As far as I can remember there is a DOM interface for traversing html etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文