使用 jQuery 和 GreaseMonkey 检测 Gmail 何时完成加载
我正在尝试使用 GreaseMonkey 脚本向 Gmail 添加一些 jQuery 内容。添加 jQuery 功能效果很好,但问题是我无法真正检测到 Gmail 何时完成加载。
这基本上是发生的情况:
- 我刷新 Gmail
- 加载窗口启动
- GM 脚本在加载窗口期间启动 3 次 加载窗口
- 中的某些内容发生变化
- GM 脚本再次启动
- 页面发生变化
- GM 脚本最后一次启动
- Gmail 视图加载和完成
此时,一堆 JavaScript 已加载到 DOM 中,这些 JavaScript 可能会调用一些使用 AJAX 加载视图其余部分的函数。
我希望 jQuery 在第 8 步之后(当所有内容都完成加载后)执行一些操作。
有谁知道如何做到/检测到这一点?
I'm trying to add some jQuery stuff to Gmail using a GreaseMonkey script. Adding jQuery functionality works fine, but the problem is that I can't really detect when Gmail has finished loading.
This is basically what happens:
- I refresh Gmail
- The loading window starts
- The GM script starts 3 times, during the loading window
- Something in the loading window changes
- The GM script starts one more time
- The page changes
- The GM script starts for the last time
- Gmail view loads and finishes
At this point a bunch of JavaScript has been loaded into the DOM that probably calls on some functions that use AJAX to load the rest of the view.
I'd like for jQuery to do stuff after step 8, when everything has finished loading.
Does anyone know how to do/detect this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您可以要求 Google 修复其 gmail-greasemonkey API - - 似乎每天都会打破更多。具体来说,
registerViewChangeCallback()
将有助于解决方案,但它似乎已停止正常工作。解决方法是延迟触发主要文档更改。以下代码似乎对我来说在 Firefox 上有效。它可能需要调整 iFrame 内容。
First, you can yell at Google to fix their gmail-greasemonkey API -- which seems to break more each day. Specifically,
registerViewChangeCallback()
would facilitate a solution but it seems to have stopped working correctly.A workaround would be to delay-fire off main document changes. The following code seems to work for me, on Firefox. It might need tweaking for iFrame content.