diff options
author | Simon Parri <simonparri@ganzeria.com> | 2025-09-23 13:22:50 -0500 |
---|---|---|
committer | Simon Parri <simonparri@ganzeria.com> | 2025-09-23 13:22:50 -0500 |
commit | 0e76241a4cfb5f532ef73ae8ecc03cb884b7552b (patch) | |
tree | 93d209ca2c1b82632afc1d1cba5d9de924346872 | |
parent | 0fc50e1bf120d6544165801a42bcc8757d02fe24 (diff) | |
download | TabFS-0e76241a4cfb5f532ef73ae8ecc03cb884b7552b.tar.gz TabFS-0e76241a4cfb5f532ef73ae8ecc03cb884b7552b.zip |
Always focus opened tab in /tabs/create-reusecapture
-rw-r--r-- | extension/background.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/extension/background.js b/extension/background.js index fbd946e..5765379 100644 --- a/extension/background.js +++ b/extension/background.js @@ -75,7 +75,7 @@ const utf8ArrayToBase64 = async (data) => { /* The result looks like - "data:application/octet-stream;base64,<your base64 data>", + "data:application/octet-stream;base64,<your base64 data>", so we split off the beginning: */ return base64url.split(",", 2)[1] @@ -184,7 +184,7 @@ const makeRouteWithContents = (function() { // Helper function: returns a route handler for `path` based on all // the children of `path` that already exist in Routes. -// +// // e.g., if `Routes['/tabs/create']` and `Routes['/tabs/by-id']` and // `Routes['/tabs/last-focused']` are all already defined, then // `makeDefaultRouteForDirectory('/tabs')` will return a route that @@ -231,9 +231,8 @@ Routes["/tabs/create-reuse"] = { else if (new URL(tab.url).hash != hash) { await browser.tabs.executeScript(tab.id, {code: `window.location = ${JSON.stringify(url)}`}) - await browser.tabs.update(tab.id, - {active: true}) } + await browser.tabs.update(tab.id, {active: true}) return {size: stringToUtf8Array(buf).length}; }, async truncate() { return {}; } @@ -400,7 +399,7 @@ function createWritableDirectory() { // writable directory that users can put arbitrary stuff into. It's // not itself a route, but it has .routeForRoot and // .routeForFilename properties that are routes. - + const dir = {}; return { directory: dir, @@ -745,7 +744,7 @@ Routes["/windows/#WINDOW_ID/visible-tab.png"] = { ...makeRouteWithContents(async } }; -Routes["/extensions"] = { +Routes["/extensions"] = { async readdir() { const infos = await browser.management.getAll(); return { entries: [".", "..", ...infos.map(info => `${sanitize(info.name)}.${info.id}`)] }; @@ -903,7 +902,7 @@ for (let key in Routes) { // if readdir -> directory -> add getattr, opendir, releasedir if (Routes[key].readdir) { Routes[key] = { - getattr() { + getattr() { return { st_mode: unix.S_IFDIR | 0755, st_nlink: 3, @@ -928,7 +927,7 @@ for (let key in Routes) { }, ...Routes[key] }; - + } else if (Routes[key].read || Routes[key].write) { Routes[key] = { async getattr() { @@ -952,7 +951,7 @@ const sortedRoutes = Object.values(Routes).sort((a, b) => function tryMatchRoute(path) { if (path.match(/\/\._[^\/]+$/)) { // Apple Double ._whatever file for xattrs - throw new UnixError(unix.ENOTSUP); + throw new UnixError(unix.ENOTSUP); } for (let route of sortedRoutes) { @@ -1038,7 +1037,7 @@ function tryConnect() { }); return; } - + port = chrome.runtime.connectNative('com.rsnous.tabfs'); port.onMessage.addListener(onMessage); port.onDisconnect.addListener(p => { @@ -1050,9 +1049,8 @@ function tryConnect() { if (typeof process === 'object') { // we're running in node (as part of a test) // return everything they might want to test - module.exports = {Routes, tryMatchRoute}; + module.exports = {Routes, tryMatchRoute}; } else { tryConnect(); } - |