summaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2021-09-15 23:36:45 -0700
committerOmar Rizwan <omar@omar.website>2021-09-15 23:36:45 -0700
commite0ec25487226fc699104a25c1084e6155f22f5e2 (patch)
treef0a7f078673b90026c97ee2e1c876d676f6209d9 /extension
parentb7bcef30e77bac2ed76388fca95cbebf0b7f3972 (diff)
downloadTabFS-e0ec25487226fc699104a25c1084e6155f22f5e2.tar.gz
TabFS-e0ec25487226fc699104a25c1084e6155f22f5e2.zip
extension: support allFrames in evals/
tweak routes.html language slightly
Diffstat (limited to 'extension')
-rw-r--r--extension/background.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/extension/background.js b/extension/background.js
index 5d34874..4bd9bec 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -362,12 +362,16 @@ function createWritableDirectory() {
Routes["/tabs/by-id/#TAB_ID/evals/:FILENAME"] = {
...evals.routeForFilename,
// FIXME: use $0 here
+ // FIXME: document allFrames option
usage: ['echo "2 + 2" > tabs/by-id/#TAB_ID/evals/twoplustwo.js',
'cat tabs/by-id/#TAB_ID/evals/twoplustwo.js.result'],
async write(req) {
const ret = await evals.routeForFilename.write(req);
const code = evals.directory[req.path];
- evals.directory[req.path + '.result'] = JSON.stringify((await browser.tabs.executeScript(req.tabId, {code}))[0]) + '\n';
+ const allFrames = req.path.endsWith('.all-frames.js');
+ // TODO: return other results beyond [0] (when all-frames is on)
+ const result = (await browser.tabs.executeScript(req.tabId, {code, allFrames}))[0];
+ evals.directory[req.path + '.result'] = JSON.stringify(result) + '\n';
return ret;
}
};
@@ -699,7 +703,7 @@ Routes["/runtime/routes.html"] = makeRouteWithContents(async () => {
<body>
<p>This page is automatically generated from <a href="https://github.com/osnr/TabFS/blob/master/extension/background.js">extension/background.js in the TabFS source code</a>.</p>
<p>It documents each of the folders and files that TabFS serves up from your browser.</p>
- <p>Variables here, like :TAB_TITLE and #TAB_ID, are stand-ins for concrete values of what you actually have open in your browser.</p>
+ <p>Variables in this document, like :TAB_TITLE and #TAB_ID, are stand-ins for concrete values of what you actually have open in your browser in a running TabFS.</p>
<p>(work in progress)</p>
<dl>
` + Object.entries(Routes).map(([path, {usage, description, __isInfill, readdir}]) => {