diff options
author | Omar Rizwan <omar.rizwan@gmail.com> | 2019-02-28 01:19:37 -0800 |
---|---|---|
committer | Omar Rizwan <omar.rizwan@gmail.com> | 2019-02-28 01:19:37 -0800 |
commit | 840526a17e252bba9ce283d2947a65d695c7f9b7 (patch) | |
tree | 74651cf79a95c62c4df7b7599d2daf9dac17a9d1 /extension | |
parent | a3f25d346f5b17bfbfbac13265812f3360e9fe45 (diff) |
extension: Add /text route.
Diffstat (limited to 'extension')
-rw-r--r-- | extension/background.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/extension/background.js b/extension/background.js index 0d3186b..c02d8d5 100644 --- a/extension/background.js +++ b/extension/background.js @@ -115,6 +115,19 @@ const router = { return (tab.title + "\n").substr(offset, size); } }, + "text": { + async read(path, fh, size, offset) { + const tabId = parseInt(pathComponent(path, -2)); + if (!debugged[tabId]) { + await new Promise(resolve => chrome.debugger.attach({tabId}, "1.3", resolve)); + debugged[tabId] = 0; + } + debugged[tabId] += 1; + await sendDebuggerCommand(tabId, "Runtime.enable", {}); + const {result} = await sendDebuggerCommand(tabId, "Runtime.evaluate", {expression: "document.body.innerText", returnByValue: true}); + return result.value.substr(offset, size) + } + }, "tree": { async opendir(path) { const tabId = parseInt(pathComponent(path, -2)); |