diff options
author | Omar Rizwan <omar.rizwan@gmail.com> | 2020-11-22 04:42:16 -0800 |
---|---|---|
committer | Omar Rizwan <omar.rizwan@gmail.com> | 2020-11-22 04:42:16 -0800 |
commit | 6b54c8ec6bc329a4fd7656627dae9ab44acb7936 (patch) | |
tree | 198194fb30e59189454db0b02628039b4b9ba167 /extension/background.js | |
parent | 9517494cd5ca186c78c3e2908b8f81251da4c44d (diff) |
re-add (buggy) resource file support
Diffstat (limited to 'extension/background.js')
-rw-r--r-- | extension/background.js | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/extension/background.js b/extension/background.js index 80567dc..b467eec 100644 --- a/extension/background.js +++ b/extension/background.js @@ -137,7 +137,35 @@ router["/tabs/by-id/*/resources"] = { const {frameTree} = await sendDebuggerCommand(tabId, "Page.getResourceTree", {}); return frameTree.resources.map(r => sanitize(String(r.url).slice(0, 200))); } -} +}; +router["/tabs/by-id/*/resources/*"] = { + async read(path, fh, size, offset) { + const tabId = parseInt(pathComponent(path, -3)); + const suffix = pathComponent(path, -1); + + if (!debugging[tabId]) throw new UnixError(unix.EIO); + + await sendDebuggerCommand(tabId, "Page.enable", {}); + + const {frameTree} = await sendDebuggerCommand(tabId, "Page.getResourceTree", {}); + for (let resource of frameTree.resources) { + const resourceSuffix = sanitize(String(resource.url).slice(0, 200)); + if (resourceSuffix === suffix) { + let {base64Encoded, content} = await sendDebuggerCommand(tabId, "Page.getResourceContent", { + frameId: frameTree.frame.id, + url: resource.url + }); + if (base64Encoded) { + const buf = btoa(atob(content).substr(offset, size)); + return { buf, base64Encoded: true }; + } + return content.substr(offset, size); + } + } + throw new UnixError(unix.ENOENT); + } +}; + router["/tabs/by-id/*/control"] = { // echo remove >> mnt/tabs/by-id/1644/control async write(path, buf) { |