Skip to content

Commit

Permalink
Accept Tab object as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed May 27, 2017
1 parent 77d2864 commit 7891e1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ import 'webext-content-script-ping'; // this only responds to the ping

## API

#### pingContentScript(tabId)
#### pingContentScript(tab)

Returns a Promise that succeeds if the content was loaded, fails if it wasn't.

It has an internal timeout of 300ms.

##### tabId
##### tab

Type: `number`
Type: `Tab` or `number`

The Tab's id as defined here: https://developer.chrome.com/extensions/tabs#type-Tab
A `Tab` object or just its `id` as defined here: https://developer.chrome.com/extensions/tabs#type-Tab

## Related

Expand Down
4 changes: 2 additions & 2 deletions webext-content-script-ping.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// https://github.com/bfred-it/webext-content-script-ping

function pingContentScript(tabId) {
function pingContentScript(tab) {
return new Promise((resolve, reject) => {
setTimeout(reject, 300);
chrome.tabs.sendMessage(tabId, chrome.runtime.id, {
chrome.tabs.sendMessage(tab.id || tab, chrome.runtime.id, {
// Only the main frame is necessary;
// if that isn't loaded, no other iframe is
frameId: 0
Expand Down

0 comments on commit 7891e1f

Please sign in to comment.