-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from codemonkey-uk/browser-action
bug fixes and improved support for dynamic websites (azure) with thanks to chaoscreater for reporting and test assist
- Loading branch information
Showing
6 changed files
with
434 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// background.js | ||
|
||
// this is just so we can trigger a full pass from the browser button | ||
// depends on polyfill for cross-browser compatibility | ||
|
||
function onError(error) { | ||
console.error(`Error: ${error}`); | ||
} | ||
|
||
function sendMessageToTabs(tabs) { | ||
for (let tab of tabs) { | ||
browser.tabs.sendMessage( | ||
tab.id, | ||
{greeting: "local_time"} | ||
).then(response => { | ||
console.log("Message from the content script:"); | ||
console.log(response.response); | ||
}).catch(onError); | ||
} | ||
} | ||
|
||
browser.browserAction.onClicked.addListener(() => { | ||
browser.tabs.query({ | ||
currentWindow: true, | ||
active: true | ||
}).then(sendMessageToTabs).catch(onError); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.