From 48fc59027ddc1fe3049e4e51e91c63dbe7275db3 Mon Sep 17 00:00:00 2001 From: KeithHenry Date: Tue, 4 Apr 2017 08:41:38 +0100 Subject: [PATCH] Added injection details --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 98cf549..a538162 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ try{ // The function will be .toString and applied to the {code:} property const results = await chrome.tabs.executeAsyncFunction(activeTab.id, scriptToExecute); - // results now holds the result of the asynchronous code run in the page + // results now holds the output of the asynchronous code run in the page } catch(err) { // Any error either setting up or executing the script @@ -135,6 +135,10 @@ catch(err) { } ``` +`chrome.tabs.executeAsyncFunction` can take a `function`, `string`, or [`executeScript` details](https://developer.chrome.com/extensions/tabs#method-executeScript) with the `code` property set. The script must be `async` or return a `Promise`. Details with a `file` property are not supported. Scripts that output multiple values are not supported. + +Unlike `chrome.tabs.executeScript` this can take a `function`, but note that it just converts the function to a string to pass it. This means that it must be self contained (it cannot call other user defined functions) and it cannot be native (as many serialise to `function foobar() { [native code] }`). + This is held in its own file: [`execute-async-function.js`](execute-async-function.js): ```html