diff options
author | Omar Rizwan <omar@omar.website> | 2020-12-12 02:51:09 -0800 |
---|---|---|
committer | Omar Rizwan <omar@omar.website> | 2020-12-12 02:51:09 -0800 |
commit | 654265347c6db7e8e2b70a8577f07a93f58db3d6 (patch) | |
tree | 94372baab300e223c67fca023a4d8c7351d34348 /extension | |
parent | 08af48843b6ccb451604597796a393d861200953 (diff) |
scripts works! uses getScriptSource
Diffstat (limited to 'extension')
-rw-r--r-- | extension/background.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/extension/background.js b/extension/background.js index 48f373e..559440e 100644 --- a/extension/background.js +++ b/extension/background.js @@ -203,7 +203,6 @@ router["/tabs/by-id/*/resources"] = { }; router["/tabs/by-id/*/resources/*"] = fromStringMaker(async path => { const [tabId, suffix] = [parseInt(pathComponent(path, -3)), pathComponent(path, -1)]; - await TabManager.debugTab(tabId); await TabManager.enableDomainForTab(tabId, "Page"); const {frameTree} = await sendDebuggerCommand(tabId, "Page.getResourceTree", {}); @@ -228,11 +227,17 @@ router["/tabs/by-id/*/scripts"] = { }, async readdir({path}) { const tabId = parseInt(pathComponent(path, -2)); - return { entries: BrowserState.scriptsForTab[tabId].map(params => sanitize(params.url).slice(0, 200)) }; - /* const {frameTree} = await sendDebuggerCommand(tabId, "Debugger.scriptParsed", {}); - * return { entries: frameTree.resources.map(r => sanitize(String(r.url).slice(0, 200))) };*/ + return { entries: BrowserState.scriptsForTab[tabId].map(params => sanitize(params.url).slice(0, 200) + "_" + params.scriptId) }; } }; +router["/tabs/by-id/*/scripts/*"] = fromStringMaker(async path => { + const [tabId, suffix] = [parseInt(pathComponent(path, -3)), pathComponent(path, -1)]; + await TabManager.debugTab(tabId); await TabManager.enableDomainForTab(tabId, "Debugger"); + + const parts = path.split("_"); const scriptId = parts[parts.length - 1]; + const {scriptSource} = await sendDebuggerCommand(tabId, "Debugger.getScriptSource", {scriptId}); + return scriptSource; +}); router["/tabs/by-id/*/control"] = { // echo remove >> mnt/tabs/by-id/1644/control @@ -254,8 +259,7 @@ router["/tabs/by-title"] = { router["/tabs/by-title/*"] = { // a symbolic link to /tabs/by-id/[id for this tab] async readlink({path}) { - const parts = path.split("_"); - const id = parts[parts.length - 1]; + const parts = path.split("_"); const id = parts[parts.length - 1]; return { buf: "../by-id/" + id }; } }; |