aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
authorOmar Rizwan <omar.rizwan@gmail.com>2020-12-02 20:24:20 -0800
committerOmar Rizwan <omar.rizwan@gmail.com>2020-12-02 20:24:20 -0800
commit22aaeaa9e139e960c7b8c819962e7ff0de95ff71 (patch)
treeb3281133240666fd332fb5d21a8755e99b6d937f /extension
parent506751b3d5b2b479ffe703acdac8fb595646ab25 (diff)
base64 reads. start working on screenshot stuff.
Diffstat (limited to 'extension')
-rw-r--r--extension/background.js13
-rw-r--r--extension/manifest.json6
2 files changed, 16 insertions, 3 deletions
diff --git a/extension/background.js b/extension/background.js
index 759bd0d..3132f48 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -138,6 +138,18 @@ router["/tabs/by-id"] = {
router["/tabs/by-id/*/url"] = withTab(tab => tab.url + "\n");
router["/tabs/by-id/*/title"] = withTab(tab => tab.title + "\n");
router["/tabs/by-id/*/text"] = fromScript(`document.body.innerText`);
+router["/tabs/by-id/*/screenshot.png"] = {
+ async read({path, fh, size, offset}) {
+ const tabId = parseInt(pathComponent(path, -2));
+ await debugTab(tabId);
+ await sendDebuggerCommand(tabId, "Page.enable", {});
+
+ const {data} = await sendDebuggerCommand(tabId, "Page.captureScreenshot");
+ const arr = Uint8Array.from(atob(data), c => c.charCodeAt(0));
+ const slice = arr.slice(offset, offset + size);
+ return { buf: String.fromCharCode(...slice) };
+ }
+};
router["/tabs/by-id/*/resources"] = {
async opendir({path}) {
const tabId = parseInt(pathComponent(path, -2));
@@ -367,6 +379,7 @@ async function onMessage(req) {
try {
response = await findRoute(req.path)[req.op](req);
response.op = req.op;
+ if (response.buf) response.buf = btoa(response.buf);
} catch (e) {
console.error(e);
diff --git a/extension/manifest.json b/extension/manifest.json
index 614a6ac..5b742d7 100644
--- a/extension/manifest.json
+++ b/extension/manifest.json
@@ -1,12 +1,12 @@
{
"manifest_version": 2,
- "name": "TabFS Extension",
- "description": "Connects to TabFS filesystem",
+ "name": "TabFS",
+ "description": "Mount your browser tabs as a filesystem",
"version": "1.0",
"permissions": [
- "tabs", "debugger", "nativeMessaging",
+ "tabs", "tabCapture", "debugger", "nativeMessaging",
"unlimitedStorage",
"*://*/*"
],