mirror of
https://github.com/osnr/TabFS.git
synced 2024-05-21 15:06:47 +02:00
make screenshot.png use fromStringMaker
This commit is contained in:
parent
583611af58
commit
edb59121cc
|
@ -169,20 +169,13 @@ router["/tabs/by-id"] = {
|
||||||
router["/tabs/by-id/*/title"] = withTab(tab => tab.title + "\n");
|
router["/tabs/by-id/*/title"] = withTab(tab => tab.title + "\n");
|
||||||
router["/tabs/by-id/*/text"] = fromScript(`document.body.innerText`);
|
router["/tabs/by-id/*/text"] = fromScript(`document.body.innerText`);
|
||||||
})();
|
})();
|
||||||
router["/tabs/by-id/*/screenshot.png"] = {
|
router["/tabs/by-id/*/screenshot.png"] = fromStringMaker(async path => {
|
||||||
async open({path}) {
|
const tabId = parseInt(pathComponent(path, -2));
|
||||||
const tabId = parseInt(pathComponent(path, -2));
|
await TabManager.debugTab(tabId); await TabManager.enableDomainForTab(tabId, "Page");
|
||||||
await TabManager.debugTab(tabId); await TabManager.enableDomainForTab(tabId, "Page");
|
|
||||||
|
|
||||||
const {data} = await sendDebuggerCommand(tabId, "Page.captureScreenshot");
|
const {data} = await sendDebuggerCommand(tabId, "Page.captureScreenshot");
|
||||||
return { fh: Cache.storeObject(Uint8Array.from(atob(data), c => c.charCodeAt(0))) };
|
return 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 {}; }
|
|
||||||
};
|
|
||||||
router["/tabs/by-id/*/resources"] = {
|
router["/tabs/by-id/*/resources"] = {
|
||||||
async readdir({path}) {
|
async readdir({path}) {
|
||||||
const tabId = parseInt(pathComponent(path, -2));
|
const tabId = parseInt(pathComponent(path, -2));
|
||||||
|
|
Loading…
Reference in a new issue