@@ -212,8 +212,14 @@ HTTPSB.loadUbiquitousBlacklists = function() {
212212 }
213213 if ( details . what === 'mergeUbiquitousBlacklist' ) {
214214 mergeBlacklist ( details ) ;
215+ return ;
216+ }
217+ if ( details . what === 'listOfBlockListsLoaded' ) {
218+ onListOfBlockListsLoaded ( details ) ;
219+ return ;
215220 }
216221 } ;
222+ chrome . runtime . onMessage . addListener ( onMessageHandler ) ;
217223
218224 var removeObsoleteBlacklistsHandler = function ( store ) {
219225 if ( ! store . remoteBlacklists ) {
@@ -271,22 +277,18 @@ HTTPSB.loadUbiquitousBlacklists = function() {
271277 // Load each preset blacklist which is not disabled.
272278 var location ;
273279 while ( location = blacklistLocations . pop ( ) ) {
274- // rhill 2014-01-24: HTTPSB-maintained lists sit now in their
275- // own directory, "asset/httpsb/". Ensure smooth transition.
276- // TODO: Remove this code when everybody upgraded beyond 0.7.7.1
277- if ( location === 'assets/httpsb-blacklist.txt' && store . remoteBlacklists [ location ] . off === true ) {
278- // In case it was already processed
279- httpsb . remoteBlacklists [ 'assets/httpsb/blacklist.txt' ] . off = true ;
280- // In case it was not yet processed
281- store . remoteBlacklists [ 'assets/httpsb/blacklist.txt' ] . off = true ;
282- }
283280 // If loaded list location is not part of default list locations,
284281 // remove its entry from local storage.
285282 if ( ! httpsb . remoteBlacklists [ location ] ) {
286283 obsoleteBlacklists . push ( location ) ;
287284 blacklistLoadCount -= 1 ;
288285 continue ;
289286 }
287+ // https://github.com/gorhill/httpswitchboard/issues/218
288+ // Transfer potentially existing list title into restored list data.
289+ if ( store . remoteBlacklists [ location ] . title !== httpsb . remoteBlacklists [ location ] . title ) {
290+ store . remoteBlacklists [ location ] . title = httpsb . remoteBlacklists [ location ] . title ;
291+ }
290292 // Store details of this preset blacklist
291293 httpsb . remoteBlacklists [ location ] = store . remoteBlacklists [ location ] ;
292294 // rhill 2013-12-09:
@@ -300,13 +302,32 @@ HTTPSB.loadUbiquitousBlacklists = function() {
300302 }
301303 } ;
302304
303- chrome . runtime . onMessage . addListener ( onMessageHandler ) ;
305+ var onListOfBlockListsLoaded = function ( details ) {
306+ var httpsb = HTTPSB ;
307+ // Initialize built-in list of 3rd-party block lists.
308+ var lists = JSON . parse ( details . content ) ;
309+ for ( var location in lists ) {
310+ if ( lists . hasOwnProperty ( location ) === false ) {
311+ continue ;
312+ }
313+ httpsb . remoteBlacklists [ 'assets/thirdparties/' + location ] = lists [ location ] ;
314+ }
315+ // Now get user's selection of list of block lists.
316+ chrome . storage . local . get (
317+ { 'remoteBlacklists' : httpsb . remoteBlacklists } ,
318+ loadBlacklistsStart
319+ ) ;
320+ } ;
304321
305- // Get remote blacklist data (which may be saved locally).
306- chrome . storage . local . get (
307- { 'remoteBlacklists' : this . remoteBlacklists } ,
308- loadBlacklistsStart
309- ) ;
322+ // Reset list of 3rd-party block lists.
323+ for ( var location in this . remoteBlacklists ) {
324+ if ( location . indexOf ( 'assets/thirdparties/' ) === 0 ) {
325+ delete this . remoteBlacklists [ location ] ;
326+ }
327+ }
328+
329+ // Get new list of 3rd-party block lists.
330+ this . assets . get ( 'assets/httpsb/ubiquitous-block-lists.json' , 'listOfBlockListsLoaded' ) ;
310331} ;
311332
312333/******************************************************************************/
0 commit comments