chrome.devtools.inspectedWindow change event

后端 未结 2 568
野性不改
野性不改 2021-01-13 09:42

The Google Chrome extension API provides info on the currently open window, using chrome.devtools.inspectedWindow, but it doesn\'t provide events for when it changes. I may

2条回答
  •  抹茶落季
    2021-01-13 10:25

    I had the same challenge, and this was the only result I found in Google, so I wanted to answer with the solution I found. The key lies not in chrome.devtools.inspectedWindow, but in chrome.tabs.onUpdated. In fact, I've found chrome.tabs.* to be much more useful in general. Here's the code I'm using to watch state changes from my extension;

    chrome.tabs.onUpdated.addListener(function (tabId, changes, tabObject) {
      console.log("Status of", tabId, "is", changes.status);
      if (changes.status == "complete") {
        console.log("Tab Load Complete");
      }
    });
    

    You could also use the chrome.tabs.* API to check whether the status change happened on the current tab or not.

提交回复
热议问题