diff options
author | Omar Rizwan <omar@omar.website> | 2020-12-11 22:32:46 -0800 |
---|---|---|
committer | Omar Rizwan <omar@omar.website> | 2020-12-11 22:32:46 -0800 |
commit | edb59121cc4e95eb2992cc072d6487b1a85a0747 (patch) | |
tree | 6804a5cf52029aff02621cbce154f84b0e2ee245 /extension | |
parent | 583611af58a7bc836fcb9a19bcf16b9699acb178 (diff) |
make screenshot.png use fromStringMaker
Diffstat (limited to 'extension')
-rw-r--r-- | extension/background.js | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/extension/background.js b/extension/background.js index 238cd7d..fa17672 100644 --- a/extension/background.js +++ b/extension/background.js @@ -169,20 +169,13 @@ router["/tabs/by-id"] = { 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 open({path}) { - const tabId = parseInt(pathComponent(path, -2)); - await TabManager.debugTab(tabId); await TabManager.enableDomainForTab(tabId, "Page"); +router["/tabs/by-id/*/screenshot.png"] = fromStringMaker(async path => { + const tabId = parseInt(pathComponent(path, -2)); + await TabManager.debugTab(tabId); await TabManager.enableDomainForTab(tabId, "Page"); - const {data} = await sendDebuggerCommand(tabId, "Page.captureScreenshot"); - return { fh: Cache.storeObject(Uint8Array.from(atob(data), c => c.charCodeAt(0))) }; - }, - async read({path, fh, size, offset}) { - const slice = Cache.getObjectForHandle(fh).slice(offset, offset + size); - return { buf: String.fromCharCode(...slice) }; - }, - async release({fh}) { Cache.removeObjectForHandle(fh); return {}; } -}; + const {data} = await sendDebuggerCommand(tabId, "Page.captureScreenshot"); + return Uint8Array.from(atob(data), c => c.charCodeAt(0)); +}); router["/tabs/by-id/*/resources"] = { async readdir({path}) { const tabId = parseInt(pathComponent(path, -2)); |