问题描述
我正在尝试检测网页何时从Google Chrome DevTools扩展程序更改。
I am trying to detect when the webpage has changed from a Google Chrome DevTools Extension.
我目前有 devtools.html & ; devtools.js 检测条件是否为真,如果是,则添加开发工具面板。
I currently have a devtools.html & devtools.js that detects if a condition is true and if it is, it adds the dev tool panel.
chrome.devtools.inspectedWindow.eval(/*my test*/, function (result, exception) {
if ( exception === undefined && result === true ) {
chrome.devtools.panels.create("My Panel", "", "panel.html", function (panel) {
...
问题是,如果我打开开发工具,然后然后导航到另一个页面,它就不会重新评估条件和添加面板。我必须再次关闭并重新打开devtool。
The problem is, if I open up the dev tool, and then navigate to another page, it doesn't re-evaluate the condition and add the panel. I have to close and reopen the devtool again.
我认为我可以执行此操作一个背景页面,我也通过了 tabId ,但没有查看如何这样做,但如果有一个非常的话,我不想沿着这条路走下去简单的技术我忽略了。
I think I could do this with a background page that I pass the tabId too, but not looked into how to do this yet, but I don't want to go down that route if there is a very simple technique I have overlooked.
另外,我还没有找到关于 Remo的任何信息ving 我的面板一旦创建,如果以前满足条件,但不再在页面导航后。
Also, I have yet to find any information on Removing my panel once it has been created if the conditions were previously met, but no longer after a page navigation.
推荐答案
是的。我想你可以使用而不是。用于检测状态更改的示例代码可以是:
Yes. I think you can use chrome.tabs.onUpdated
instead. Sample code to detect the state changes can be:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.status == 'complete') {
}
});
这篇关于谷歌Chrome DevTools扩展 - 检测页面更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!