mirror of
https://github.com/osnr/TabFS.git
synced 2024-06-15 20:25:18 +02:00
add by-window symlinks
This commit is contained in:
parent
e0ec254872
commit
6cf4c2630d
|
@ -210,6 +210,7 @@ Routes["/tabs/by-title"] = {
|
|||
return { entries: [".", "..", ...tabs.map(tab => sanitize(String(tab.title)) + "." + String(tab.id))] };
|
||||
}
|
||||
};
|
||||
|
||||
Routes["/tabs/by-title/:TAB_TITLE.#TAB_ID"] = {
|
||||
description: `Represents one open tab.
|
||||
It's a symbolic link to the folder /tabs/by-id/#TAB_ID.`,
|
||||
|
@ -223,6 +224,38 @@ It's a symbolic link to the folder /tabs/by-id/#TAB_ID.`,
|
|||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
Routes["/tabs/by-window"] = {
|
||||
description: 'Open tabs, organized by window then title; each subfolder represents an open tab.',
|
||||
usage: 'ls $0',
|
||||
getattr() {
|
||||
return {
|
||||
st_mode: unix.S_IFDIR | 0777, // writable so you can delete tabs
|
||||
st_nlink: 3,
|
||||
st_size: 0,
|
||||
};
|
||||
},
|
||||
async readdir() {
|
||||
const tabs = await browser.tabs.query({});
|
||||
return { entries: [".", "..", ...tabs.map(tab => sanitize(String(tab.windowId) + "." + String(tab.title)) + "." + String(tab.id))] };
|
||||
}
|
||||
};
|
||||
|
||||
Routes["/tabs/by-window/#TAB_WINDOW_ID.:TAB_TITLE.#TAB_ID"] = {
|
||||
description: `Represents one open tab.
|
||||
It's a symbolic link to the folder /tabs/by-id/#TAB_ID.`,
|
||||
// TODO: date
|
||||
usage: ['rm $0'],
|
||||
async readlink({tabId}) {
|
||||
return { buf: "../by-id/" + tabId };
|
||||
},
|
||||
async unlink({tabId}) {
|
||||
await browser.tabs.remove(tabId);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Routes["/tabs/last-focused"] = {
|
||||
description: `Represents the most recently focused tab.
|
||||
It's a symbolic link to the folder /tabs/by-id/[ID of most recently focused tab].`,
|
||||
|
|
Loading…
Reference in a new issue