Skip to content

Commit e8cc452

Browse files
authored
Update README.md
1 parent 9e308c6 commit e8cc452

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Note that when you set a variable, the new value will be returned (just like whe
242242
## Communicate with the content scripts
243243
From version 1.1.0, you can do all the aforementioned actions from the background script too!
244244

245-
By default, the scripts are associated with their tab ids. For this reason, you should first know which tab you want to communicate with. If you have this tab id in a variable called "tabId", then you can do the following:
245+
By default, the scripts are associated with their tab ids. For this reason, you should first know which tab you want to communicate with (you can also request the tabs where a specific script is active, as shown later). If you have this tab id in a variable called "tabId", then you can do the following:
246246

247247
```js
248248
// Background script
@@ -270,6 +270,16 @@ function remoteMethod() {
270270
}
271271
```
272272

273+
You can also use a method on the BackgroundHandler to request the various tab Ids where a script is connected. This is the way to do it:
274+
```js
275+
async function broadcast() {
276+
let tabIds = await bgHandler.getScriptTabs("script-id-here");
277+
for (let id of tabIds) {
278+
// get the connection and call a method
279+
}
280+
}
281+
```
282+
273283
## API Reference
274284

275285
### BackgroundHandler class

0 commit comments

Comments
 (0)