应用于所有Facebook页面上运行的Chrome扩展只有在我刷新时运行 [英] Chrome Extension which is supposed to run on all Facebook pages only runs when I hit refresh

查看:77
本文介绍了应用于所有Facebook页面上运行的Chrome扩展只有在我刷新时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次编写Chrome扩展程序的黑客。每当Facebook页面加载时,我希望它执行一些非常简单的JavaScript。它正在做我想要的所有东西除了,由于某种原因,它只会运行我的脚本,如果我点击刷新按钮。如果,例如我点击了Facebook徽标,或者我从我的通知中转到状态,脚本不会运行...直到我点击刷新。

This is my first hack at writing a Chrome extension. I want it to execute some pretty simple JavaScript every time a Facebook page loads. It's doing everything I want except that for some reason, it only runs my script if I hit the Refresh button. If, e.g. I clicked on the Facebook logo, or I go to a status from my notifications, the script doesn't run... until I click refresh.

这是我的清单:

{
    "name": "Anti-social Reader",
    "version": "1.0",
    "description": "Defeats 'social reader' apps on Facebook, by letting you just see the news story directly without installing the app.",
    "content_scripts": [
        {
           "matches": ["http://*.facebook.com/*", "https://*.facebook.com/*"],
           "js": ["kill_social_reader.js"],
           "run_at": "document_end",
           "all_frames": true
        }
     ]
}

我需要它等到document_end,因为它正在修改加载的页面的DOM。我确定这是愚蠢的...任何想法?

I need it to wait until document_end because it is modifying the DOM of the loaded page. I'm sure it's something stupid... any ideas?

推荐答案

在一个明显的方式是不可能的。 Facebook页面正在进行许多 ajax调用,因此该页面不会完全重新加载。您需要的是确定浏览器是否收到了ajax呼叫响应?然后触发所需的事件。我不能就这一点发表评论,因为我还是这方面的新手。

In an obvious way it is not possible. The facebook page is making numerous ajax calls, hence the page does not reload completely. What you need here is to identify whether a ajax call response has been received by the browser or not? and then triggering the event required. I can't comment on that part as I'm still a newbie in that respect.

这篇关于应用于所有Facebook页面上运行的Chrome扩展只有在我刷新时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆