javascript - Is there an alternative to preprocessorScript for Chrome DevTools extensions? -
i want create custom profiler javascript chrome devtools extension. so, i'd have instrument javascript code of website (parse ast, inject hooks, generate new source). should've been possible using chrome.devtools.inspectedwindow.reload()
, parameter preprocessorscript
described here: https://developer.chrome.com/extensions/devtools_inspectedwindow.
unfortunately, feature has been removed (https://bugs.chromium.org/p/chromium/issues/detail?id=438626) because nobody using it.
do know of other way achieve same thing chrome extension? there other way can replace incoming javascript source changed version? question specific chrome extensions (and maybe extensions other browsers), i'm asking last resort before going different route (e.g. dedicated app).
on http can use chrome.webrequest api redirect requests js code data urls containing processed javascript code.
however, won't work inline script tags. won't work on https, since data urls considered unsafe. , data urls can't longer 2mb in chrome, won't able redirect large js files.
if exact order of execution of each script isn't important cancel script requests , later send message script content page. make work on https.
to address both issues redirect html page data url, in order gain more control. has few negative consequences though:
- can't reload page because url fixed data url
- need add or update
<base>
tag make sure stylesheet/image urls go correct url - breaks ajax requests require cookies/authentication (not sure if can fixed)
- no support localstorage on data urls
not sure if works: in order fix #1 , #4 consider setting html page within chrome extension , using base page instead of data url.
another idea may or may not work: use chrome.debugger
modify source code.
Comments
Post a Comment