javascriptgoogle-chromecode-snippets

chrome-devtools snippets import/export 2016


Today I wanted to export my snippets from chrome.

I found Information from 2013: https://github.com/bgrins/devtools-snippets/issues/28#issuecomment-27455522

I opened the DevTools -> to sperate Window -> Inspect the Devtools Itself

Then in Console:

->localStorage.scriptSnippets
undefined
->var stringifiedSnippets = localStorage.getItem('scriptSnippets');
undefined
->stringifiedSnippets
null

I tested Chrome 48 (windows), Chromium 45(ubuntu) and a Friends Chrome on his Macbook. How can I access my Snippets.

Has the API changed? Or am I making a mistake here. Thanks.


Solution

  • Yes, the internals have changed. Your code should change to the following:

    InspectorFrontendHost.getPreferences(function(prefs) {
        console.log(prefs.scriptSnippets);
    });
    

    Note: This script shall be run in second depth Dev Tools window! Make sure that the developer tools are undocked into a new window. Then press Ctrl+Shift+i (Command+Option+i) to open DevTools of DevTools. In that second DevTools window, run the script above.