@@ -74,35 +74,37 @@ sendMessageToHost({
7474 version : "2.0.9"
7575} ) ;
7676
77- // Read the local storage for excluded keywords
78- if ( localStorage [ "uget-keywords-exclude" ] ) {
79- keywordsToExclude = localStorage [ "uget-keywords-exclude" ] . split ( / [ \s , ] + / ) ;
80- } else {
81- localStorage [ "uget-keywords-exclude" ] = '' ;
82- }
83-
84- // Read the local storage for included keywords
85- if ( localStorage [ "uget-keywords-include" ] ) {
86- keywordsToInclude = localStorage [ "uget-keywords-include" ] . split ( / [ \s , ] + / ) ;
87- } else {
88- localStorage [ "uget-keywords-include" ] = '' ;
89- }
77+ // Read the storage for excluded keywords
78+ current_browser . storage . sync . get ( function ( items ) {
79+ if ( items [ "uget-keywords-exclude" ] ) {
80+ keywordsToExclude = items [ "uget-keywords-exclude" ] . split ( / [ \s , ] + / ) ;
81+ } else {
82+ current_browser . storage . sync . set ( { "uget-keywords-exclude" : '' } ) ;
83+ }
9084
91- // Read the local storage for the minimum file-size to interrupt
92- if ( localStorage [ "uget-min-file-size " ] ) {
93- minFileSizeToInterrupt = parseInt ( localStorage [ "uget-min-file-size" ] ) ;
94- } else {
95- localStorage [ "uget-min-file-size" ] = minFileSizeToInterrupt ;
96- }
85+ // Read the local storage for included keywords
86+ if ( items [ "uget-keywords-include " ] ) {
87+ keywordsToInclude = items [ "uget-keywords-include" ] . split ( / [ \s , ] + / ) ;
88+ } else {
89+ current_browser . storage . sync . set ( { "uget-keywords-include" : '' } ) ;
90+ }
9791
98- // Read the local storage for enabled flag
99- if ( ! localStorage [ "uget-interrupt" ] ) {
100- localStorage [ "uget-interrupt" ] = 'true' ;
101- } else {
102- var interrupt = ( localStorage [ "uget-interrupt" ] == "true" ) ;
103- setInterruptDownload ( interrupt ) ;
104- }
92+ // Read the local storage for the minimum file-size to interrupt
93+ if ( items [ "uget-min-file-size" ] ) {
94+ minFileSizeToInterrupt = parseInt ( items [ "uget-min-file-size" ] ) ;
95+ } else {
96+ current_browser . storage . sync . set ( { "uget-min-file-size" : minFileSizeToInterrupt } ) ;
97+ }
10598
99+ // Read the local storage for enabled flag
100+ if ( ! items [ "uget-interrupt" ] ) {
101+ // Keep the value string
102+ current_browser . storage . sync . set ( { "uget-interrupt" : 'true' } ) ;
103+ } else {
104+ var interrupt = ( items [ "uget-interrupt" ] == "true" ) ;
105+ setInterruptDownload ( interrupt ) ;
106+ }
107+ } ) ;
106108// Message format to send the download information to the uget-chrome-wrapper
107109var message = {
108110 url : '' ,
@@ -464,6 +466,8 @@ function parseCookies(cookies_arr) {
464466function updateKeywords ( include , exclude ) {
465467 keywordsToInclude = include . split ( / [ \s , ] + / ) ;
466468 keywordsToExclude = exclude . split ( / [ \s , ] + / ) ;
469+ current_browser . storage . sync . set ( { "uget-keywords-include" : include } ) ;
470+ current_browser . storage . sync . set ( { "uget-keywords-exclude" : exclude } ) ;
467471}
468472
469473/**
@@ -472,6 +476,7 @@ function updateKeywords(include, exclude) {
472476 */
473477function updateMinFileSize ( size ) {
474478 minFileSizeToInterrupt = size ;
479+ current_browser . storage . sync . set ( { "uget-min-file-size" : size } ) ;
475480}
476481
477482/**
@@ -519,6 +524,6 @@ function setInterruptDownload(interrupt, writeToStorage) {
519524 } ) ;
520525 }
521526 if ( writeToStorage ) {
522- localStorage [ "uget-interrupt" ] = interrupt . toString ( ) ;
527+ current_browser . storage . sync . set ( { "uget-interrupt" : interrupt . toString ( ) } ) ;
523528 }
524529}
0 commit comments