Description
Hey, first of all, thanks for making this extension.
While using it I found that on some websites the console gets cluttered and sometimes it's easy to get lost in the logs. I thought it'd nice if there was a panel in DevTools where you could filter or search the logs, just like the Network panel.
I initially wanted to do a PR, but I kept adding more stuff and added Svelte+TypeScript for the UI, so I thought it might be better if I publish it into a separate repo, or let me know what you think...
The new features are:
Panel in DevTools, where you can:
- filter by sink type
- filter by code in the input
- choose to preserve log after navigation/reload
- clear the log
- modify settings (which are saved in
chrome.storage
)- all the original settings (list of keywords, list of source/any call stack substrings to ignore, trace limit, only log highlighted) +
- highlighting options (it uses
Document.execCommand hiliteColor
for highlighting, which is slow, but works) - group the console.trace/logs in console using console.group to keep the console a bit more tidy
- view found sinks
- with syntax highlighted input code
- or open the code in a popup window
- the href url
- the stack trace
- The stack trace is a bit unfortunate since it can't be formatted nicely with clickable links (as console.trace does), but as an alternative I've given each stack trace a unique ID which you can copy by clicking it, and then just filter by the ID in console to find it. Obviously that won't work if you clear the console, but other than that is should work fine.
Injected script
Since the chrome.storage
are all asynchronous I thought it wouldn't be possible to fetch the settings in the injected script, but it's actually possible to intercept the settings.json
XMLHttpRequest, and redirect the request to data:application/json,{settings:...}
, will gives us synchronous access to the dynamic settings directly in the injected script.
The injected script <> extension communication is via postMessage
s, which is also not ideal, but seems to be the only possible way.
Here's a screenshot of the DevTools panel:
The repository can be found at: https://github.com/ThomasOrlita/untrusted-types-devtools
Thanks!