Chrome Extensions - Saving Settings

后端 未结 1 1710
执笔经年
执笔经年 2021-01-13 06:43

I\'m building my first Chrome extension. It\'s a very simple thing I\'m trying to do at this point so I can try and gain an understanding of how it works and build off of th

相关标签:
1条回答
  • 2021-01-13 07:14

    to save

    chrome.storage.sync.set({ mytext: txtValue });
    

    to get

    chrome.storage.sync.get('mytext', function(data) {
        yourTextArea.value = data.mytext;
    });
    

    I found a new library to call chrome storage with Promise, pretty cool.

    https://github.com/Selection-Translator/chrome-call

    import { scope } from 'chrome-call'
    
    const storage = scope('storage.local')
    storage('get', 'flows').then(data => initFlows(data.flows))
    
    0 讨论(0)
提交回复
热议问题