@@ -9,21 +9,22 @@ var defaults = {
9
9
"preserveFirst" : false ,
10
10
"showCounter" : true ,
11
11
"substitutionMark" : true ,
12
- "words" : {
13
- "ass" : { "matchMethod" : 0 , "words" : [ "butt" , "tail" ] } ,
14
- "asshole" : { "matchMethod" : 1 , "words" : [ "butthole" , "jerk" ] } ,
15
- "bastard" : { "matchMethod" : 1 , "words" : [ "imperfect" , "impure" ] } ,
16
- "bitch" : { "matchMethod" : 1 , "words" : [ "jerk" ] } ,
17
- "cunt" : { "matchMethod" : 1 , "words" : [ "explative" ] } ,
18
- "damn" : { "matchMethod" : 1 , "words" : [ "dang" , "darn" ] } ,
19
- "fuck" : { "matchMethod" : 1 , "words" : [ "freak" , "fudge" ] } ,
20
- "piss" : { "matchMethod" : 1 , "words" : [ "pee" ] } ,
21
- "pissed" : { "matchMethod" : 0 , "words" : [ "ticked" ] } ,
22
- "slut" : { "matchMethod" : 1 , "words" : [ "imperfect" , "impure" ] } ,
23
- "shit" : { "matchMethod" : 1 , "words" : [ "crap" , "crud" , "poop" ] } ,
24
- "tits" : { "matchMethod" : 1 , "words" : [ "explative" ] } ,
25
- "whore" : { "matchMethod" : 1 , "words" : [ "harlot" , "tramp" ] }
26
- }
12
+ "words" : { }
13
+ } ;
14
+ var defaultWords = {
15
+ "ass" : { "matchMethod" : 0 , "words" : [ "butt" , "tail" ] } ,
16
+ "asshole" : { "matchMethod" : 1 , "words" : [ "butthole" , "jerk" ] } ,
17
+ "bastard" : { "matchMethod" : 1 , "words" : [ "imperfect" , "impure" ] } ,
18
+ "bitch" : { "matchMethod" : 1 , "words" : [ "jerk" ] } ,
19
+ "cunt" : { "matchMethod" : 1 , "words" : [ "explative" ] } ,
20
+ "damn" : { "matchMethod" : 1 , "words" : [ "dang" , "darn" ] } ,
21
+ "fuck" : { "matchMethod" : 1 , "words" : [ "freak" , "fudge" ] } ,
22
+ "piss" : { "matchMethod" : 1 , "words" : [ "pee" ] } ,
23
+ "pissed" : { "matchMethod" : 0 , "words" : [ "ticked" ] } ,
24
+ "slut" : { "matchMethod" : 1 , "words" : [ "imperfect" , "impure" ] } ,
25
+ "shit" : { "matchMethod" : 1 , "words" : [ "crap" , "crud" , "poop" ] } ,
26
+ "tits" : { "matchMethod" : 1 , "words" : [ "explative" ] } ,
27
+ "whore" : { "matchMethod" : 1 , "words" : [ "harlot" , "tramp" ] }
27
28
} ;
28
29
var filterMethods = [ "Censor" , "Substitute" , "Remove" ] ;
29
30
var matchMethods = [ "Exact Match" , "Partial Match" , "Whole Match" , "Per-Word Match" ] ;
@@ -154,7 +155,7 @@ function migrateWordList() {
154
155
if ( word != "" ) {
155
156
if ( ! arrayContains ( Object . keys ( config . words ) , word ) ) {
156
157
console . log ( 'Migrating word: ' + word ) ;
157
- config . words [ word ] = { "matchMethod" : 1 , "words" : [ ] } ;
158
+ config . words [ word ] = { "matchMethod" : 0 , "words" : [ ] } ;
158
159
} else {
159
160
console . log ( 'Word already in list: ' + word ) ;
160
161
}
@@ -198,6 +199,11 @@ function populateOptions() {
198
199
chrome . storage . sync . get ( defaults , function ( settings ) {
199
200
config = settings ; // Make config globally available
200
201
migrateWordList ( ) ; // TODO: Migrate wordList
202
+ if ( Object . keys ( config . words ) . length === 0 && config . words . constructor === Object ) {
203
+ config . words = defaultWords ;
204
+ saveOptions ( null , config ) ;
205
+ return false ;
206
+ }
201
207
202
208
// Show/hide censor options and word substitutions based on filter method
203
209
dynamicList ( filterMethods , 'filterMethodSelect' ) ;
@@ -332,7 +338,6 @@ function wordAdd(event) {
332
338
if ( ! arrayContains ( Object . keys ( config . words ) , word ) ) {
333
339
config . words [ word ] = { "matchMethod" : 1 , "words" : [ ] } ;
334
340
saveOptions ( event , config ) ;
335
- dynamicList ( Object . keys ( config . words ) , 'wordSelect' , 'Words to Filter' ) ;
336
341
document . getElementById ( 'wordText' ) . value = "" ;
337
342
} else {
338
343
updateStatus ( 'Word already in list.' , true , 3000 ) ;
@@ -360,7 +365,6 @@ function wordRemove(event) {
360
365
if ( word != "" ) {
361
366
delete config . words [ word ] ;
362
367
saveOptions ( event , config ) ;
363
- dynamicList ( Object . keys ( config . words ) , 'wordSelect' , 'Words to Filter' ) ;
364
368
}
365
369
}
366
370
0 commit comments