diff options
author | Omar Rizwan <omar@omar.website> | 2021-01-03 20:09:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-03 20:09:07 -0800 |
commit | 11834af93650645b902d3c1974f26d85f775c1f8 (patch) | |
tree | e841903f48a13cbece117c4d3ef310c94efcd57c | |
parent | f875d56b0741099569a2bac82acc1d3a937dcb83 (diff) | |
parent | 8946ca34b872fe46b8abe2afd87e03b6be5bf6a0 (diff) |
Merge pull request #32 from 4z3/activate
Add /tabs/by-id/*/active
-rw-r--r-- | extension/background.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/extension/background.js b/extension/background.js index 1b1cad0..7851b22 100644 --- a/extension/background.js +++ b/extension/background.js @@ -344,6 +344,24 @@ router["/tabs/by-id/*/control"] = { }, async truncate({path, size}) { return {}; } }; +router["/tabs/by-id/*/active"] = { + // echo true > mnt/tabs/by-id/1644/active + // cat mnt/tabs/by-id/1644/active + async read({path, fh, offset, size}) { + const tabId = parseInt(pathComponent(path, -2)); + const tab = await browser.tabs.get(tabId); + const buf = (JSON.stringify(tab.active) + '\n').slice(offset, offset + size); + return { buf }; + }, + async write({path, buf}) { + if (buf.trim() === "true") { + const tabId = parseInt(pathComponent(path, -2)); + await browser.tabs.update(tabId, { active: true }); + } + return {size: stringToUtf8Array(buf).length}; + }, + async truncate({path, size}) { return {}; } +}; // debugger/ : debugger-API-dependent (Chrome-only) (function() { |