From 654265347c6db7e8e2b70a8577f07a93f58db3d6 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Sat, 12 Dec 2020 02:51:09 -0800 Subject: scripts works! uses getScriptSource --- extension/background.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'extension') 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 }; } }; -- cgit v1.2.3