summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrob cobb <rwcobbjr@gmail.com>2022-01-07 16:22:16 -0500
committerrob cobb <rwcobbjr@gmail.com>2022-01-07 16:22:16 -0500
commitbf7edaec22512dd385e95d2eba49287a45288cce (patch)
treebda8aeff52195771db082b5929a9a051e0970269
parent6cf4c2630dc15d08ddde1f87860004233f8f3492 (diff)
downloadTabFS-bf7edaec22512dd385e95d2eba49287a45288cce.tar.gz
TabFS-bf7edaec22512dd385e95d2eba49287a45288cce.zip
add tabs directory to window
-rw-r--r--extension/background.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/extension/background.js b/extension/background.js
index cd5e5f3..1655d5a 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -628,6 +628,24 @@ Routes["/windows"] = {
return { entries: [".", "..", ...windows.map(window => String(window.id))] };
}
};
+
+Routes["/windows/#WINDOW_ID/tabs"] = {
+ async readdir({windowId}) {
+ const tabs = await browser.tabs.query({windowId});
+ return { entries: [".", "..", ...tabs.map(tab => sanitize(String(tab.title) + "." + String(tab.id))) ] }
+ }
+}
+
+Routes["/windows/#WINDOW_ID/tabs/:TAB_TITLE.#TAB_ID"] = {
+ async readlink({tabId}) {
+ return { buf: "../../../tabs/by-id/" + tabId };
+ },
+ async unlink({tabId}) {
+ await browser.tabs.remove(tabId);
+ return {};
+ }
+}
+
Routes["/windows/last-focused"] = {
description: `A symbolic link to /windows/[id for the last focused window].`,
async readlink() {
@@ -635,6 +653,7 @@ Routes["/windows/last-focused"] = {
return { buf: windowId };
}
};
+
(function() {
const withWindow = (readHandler, writeHandler) => makeRouteWithContents(async ({windowId}) => {
const window = await browser.windows.get(windowId);