@@ -22,12 +22,9 @@ var Settings = {
2222
2323 async import ( data ) {
2424
25- // figure out whether it's just a whitelist , a legacy backup or a "Quantum" export
25+ // figure out whether it's just a trusted/untrusted list , a serialized policy or a full settings export
2626 try {
2727 let json = JSON . parse ( data ) ;
28- if ( json . whitelist ) {
29- return await this . importLegacy ( json ) ;
30- }
3128 if ( json . trusted ) {
3229 return await this . importPolicy ( json ) ;
3330 }
@@ -40,26 +37,16 @@ var Settings = {
4037 }
4138 } ,
4239
43- async importLegacy ( json ) {
44- await include ( "/legacy/Legacy.js" ) ;
45- if ( await Legacy . import ( json ) ) {
46- try {
47- ns . policy = Legacy . migratePolicy ( ) ;
48- await ns . savePolicy ( ) ;
49- await Legacy . persist ( ) ;
50- return true ;
51- } catch ( e ) {
52- error ( e , "Importing legacy settings" ) ;
53- Legacy . migrated = Legacy . undo ;
54- }
55- }
56- return false ;
57- } ,
58-
5940 async importLists ( data ) {
60- await include ( "/legacy/Legacy.js" ) ;
41+ const extractLists = lists =>
42+ lists . map ( listString => listString . split ( / \s + / ) )
43+ . map ( sites => sites . filter ( s => ! (
44+ s . includes ( ":" ) &&
45+ sites . includes ( s . replace ( / .* : \/ * (? = \w ) / g, "" ) )
46+ ) ) ) ;
47+
6148 try {
62- let [ trusted , untrusted ] = Legacy . extractLists ( data . split ( "[UNTRUSTED]" ) ) ;
49+ let [ trusted , untrusted ] = extractLists ( data . split ( "[UNTRUSTED]" ) ) ;
6350 let policy = ns . policy ;
6451 for ( let site of trusted ) {
6552 policy . set ( site , policy . TRUSTED ) ;
0 commit comments