bahmutov/code-snippets

snippets are no longer available via localStorage

paulirish opened this issue · 6 comments

We made snippets (among other settings) available from incognito. I think this change landed in Chrome stable around 46/47 or so.

As a result, they are no longer available in localStorage. Here's the new technique. These are run from a devtools-on-devtools window.

getting snippets

InspectorFrontendHost.getPreferences(_ => console.log(JSON.parse(_.scriptSnippets)))

setting snippets

InspectorFrontendHost.setPreference("scriptSnippets", JSON.stringify(yourSnippets))

FWIW, InspectorFrontendHost.getPreferences will return everything that has migrated to the incognito-available settings (most things), while a few items (like breakpoints) remain in the devtools' localStorage

Tagging a few other issues that use this technique:

Thanks for the info, helped me tremendously.

I have tried updating the update-code-snippets and started to work on a gui manager script.
Seems to work ok so far:

https://github.com/soundyogi/code-snippets/blob/master/update-code-snippets.js
https://gist.github.com/soundyogi/03df95505604c8351212

I will file a PR when I added support for the old version aswell.

cool, will update the updater snippet at some point

It seems there is no way to map snippets to localSystem. Is mapping snippets to local file system a valid use case or is there something obvious I am missing?

Not that I know of, I wrote a little module "require" that required some snippets before others but even for that you need to Inspect the Inspector ... I guess snippets are to sandboxed for local mapping?

now InspectorFrontendHost is gone as well

is there any way of importing snippets now.
InspectorFrontendHost is not defined now