File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
starters/chrome/extension/lib Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,19 @@ const config = {
33 ghRepoURL : 'https://github.kudoai.com/chatgpt.js-chrome-starter' }
44
55const settings = {
6-
7- load : function ( ) {
6+ load ( ) {
87 const keys = ( // original array if array, else new array from multiple args
98 Array . isArray ( arguments [ 0 ] ) ? arguments [ 0 ] : Array . from ( arguments ) )
10- return Promise . all ( keys . map ( ( key ) => { // resolve promise when all keys load
11- return new Promise ( ( resolve ) => { // resolve promise when single key value loads
12- chrome . storage . local . get ( key , ( result ) => { // load from Chrome
9+ return Promise . all ( keys . map ( key => // resolve promise when all keys load
10+ new Promise ( resolve => // resolve promise when single key value loads
11+ chrome . storage . sync . get ( key , result => { // load from Chrome
1312 config [ key ] = result [ key ] || false ; resolve ( )
14- } ) } ) } ) ) } ,
13+ } ) ) ) ) } ,
1514
16- save : function ( key , value ) {
17- const obj = { } ; obj [ key ] = value
18- chrome . storage . local . set ( obj ) // save to Chrome
19- config [ key ] = value // save to memory
15+ save ( key , val ) {
16+ chrome . storage . sync . set ( { [ key ] : val } ) // save to Chrome
17+ config [ key ] = val // save to memory
2018 }
21-
2219}
2320
2421export { config , settings }
You can’t perform that action at this time.
0 commit comments