File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,17 @@ exports.save = save;
12
12
exports . load = load ;
13
13
exports . useColors = useColors ;
14
14
15
+ /**
16
+ * Use chrome.storage.local if we are in an app
17
+ */
18
+
19
+ var storage ;
20
+
21
+ if ( typeof chrome !== 'undefined' && typeof chrome . storage !== 'undefined' )
22
+ storage = chrome . storage . local ;
23
+ else
24
+ storage = window . localStorage ;
25
+
15
26
/**
16
27
* Colors.
17
28
*/
@@ -118,9 +129,9 @@ function log() {
118
129
function save ( namespaces ) {
119
130
try {
120
131
if ( null == namespaces ) {
121
- localStorage . removeItem ( 'debug' ) ;
132
+ storage . removeItem ( 'debug' ) ;
122
133
} else {
123
- localStorage . debug = namespaces ;
134
+ storage . debug = namespaces ;
124
135
}
125
136
} catch ( e ) { }
126
137
}
@@ -135,7 +146,7 @@ function save(namespaces) {
135
146
function load ( ) {
136
147
var r ;
137
148
try {
138
- r = localStorage . debug ;
149
+ r = storage . debug ;
139
150
} catch ( e ) { }
140
151
return r ;
141
152
}
You can’t perform that action at this time.
0 commit comments