mirror of
https://github.com/osnr/TabFS.git
synced 2024-05-19 14:06:34 +02:00
background.js: add /tabs/by-id/*/active
This commit is contained in:
parent
f875d56b07
commit
8946ca34b8
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue