From 22aaeaa9e139e960c7b8c819962e7ff0de95ff71 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Wed, 2 Dec 2020 20:24:20 -0800 Subject: base64 reads. start working on screenshot stuff. --- extension/background.js | 13 +++++++++++++ extension/manifest.json | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'extension') 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", "*://*/*" ], -- cgit v1.2.3