bahmutov / bahmutov/code-snippets

snippets are no longer available via localStorage

Open
#23 6 comments 4 reactions 0 assignees View on GitHub
enhancement quality
Dominant language
JavaScript
Stars
1.8k
Forks
196
PR merge metrics
No merged PRs in 30d

Description

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](http://stackoverflow.com/a/12291163/89484) window.
### getting snippets

``` js
InspectorFrontendHost.getPreferences(_ => console.log(JSON.parse(_.scriptSnippets)))
```
### setting snippets

``` js
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:
- #6
- https://github.com/bgrins/devtools-snippets/issues/28
- https://github.com/bgrins/devtools-snippets/pull/35
- http://stackoverflow.com/questions/19025718/which-file-does-snippets-of-chrome-dev-tool-saved-at

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.