使用 Javascript 以编程方式取消 FB 照片标签
在过去的一个小时里,我一直在研究这个问题:我想编写一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 DCoder,通过 黑客新闻:
使用 Firebug、FireQuery、jQuery 与 $jq 没有冲突,从照片页面 (http://www.facebook.com/photo.php?pid=xxx&id=y) :
它不会更新 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) :
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.
因为我不确定您是否在 HN 上获取了我的更新版本:
Since I'm not sure if you picked up my updated version at HN:
鸡足 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.