Monday, May 20, 2024
44
rated 0 times [  49] [ 5]  / answers: 1 / hits: 156717  / 13 Years ago, mon, june 27, 2011, 12:00:00

I want to make a chrome extension that executes some scripts after one page is loaded, I am not sure whether I have to implement this logic on the background page or it can be anywhere else, any help here will be greatly appreciated.


More From » google-chrome

 Answers
7

From a background script you can listen to the chrome.tabs.onUpdated event and check the property changeInfo.status on the callback. It can be loading or complete. If it is complete, do the action.


Example:


chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete') {

// do your things

}
})

Because this will probably trigger on every tab completion, you can also check if the tab is active on its homonymous attribute, like this:


chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete' && tab.active) {

// do your things

}
})

[#91478] Saturday, June 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
christianu

Total Points: 481
Total Questions: 124
Total Answers: 99

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
2 Years ago
christianu questions
;