Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -30,17 +30,17 @@ FilterNotifier.addListener(function(acti |
}); |
var toolbarButton; |
var i18nMessages; |
function importOldData() |
{ |
// TODO: Remove this once most people have the update |
- if ("version" in widget.preferences) |
+ if ("version" in widget.preferences || "last-version" in widget.preferences) |
{ |
var oldLists = { |
"fanboy": "https://secure.fanboy.co.nz/fanboy-adblock.txt", |
"fanboy-ru": "https://secure.fanboy.co.nz/fanboy-russian.txt", |
"fanboy-es": "https://secure.fanboy.co.nz/fanboy-espanol.txt", |
"fanboy-ja": "https://secure.fanboy.co.nz/fanboy-japanese.txt", |
"fanboy-cz": "https://secure.fanboy.co.nz/fanboy-czech.txt", |
"fanboy-tr": "https://secure.fanboy.co.nz/fanboy-turkish.txt", |
@@ -64,40 +64,68 @@ function importOldData() |
"easy-fi": "http://www.wiltteri.net/wiltteri.txt", |
"easy-es": "http://abp.mozilla-hispano.org/nauscopio/filtros.txt", |
"easy-hu": "http://ajnasz.hu/adblock/recent", |
"adblock-lv": "https://gitorious.org/adblock-latvian/adblock-latvian/blobs/raw/master/lists/latvian-list.txt", |
"easy-priv": "https://easylist-downloads.adblockplus.org/easyprivacy.txt", |
"easy-ru-priv": "https://ruadlist.googlecode.com/svn/trunk/cntblock.txt" |
}; |
+ // Import filter subscriptions |
for (var key in oldLists) |
{ |
if (key in widget.preferences) |
{ |
// Only add subscriptions that were enabled in old version |
if (widget.preferences[key] == "true") |
{ |
var subscription = Subscription.fromURL(oldLists[key]); |
if (subscription && !(subscription.url in FilterStorage.knownSubscriptions)) |
{ |
FilterStorage.addSubscription(subscription); |
Synchronizer.execute(subscription); |
} |
} |
- |
- delete widget.preferences[key]; |
- delete widget.preferences[key + "-content"]; |
- delete widget.preferences[key + "-time"]; |
} |
} |
- // TODO: Import custom filters? |
+ // Import custom filters |
+ if ("personal" in widget.preferences) |
+ { |
+ var customFilters = widget.preferences.personal.split("\n"); |
+ for (var i = 0; i < customFilters.length; i++) |
+ { |
+ var filter = customFilters[i]; |
+ if (filter === "") |
+ continue; |
- delete widget.preferences.version; |
+ if (filter.substr(0, 1) != "*") |
+ filter = "|" + filter; |
+ if (filter.substr(-1) != "*") |
+ filter = filter + "|"; |
+ FilterStorage.addFilter(Filter.fromText(filter)); |
+ } |
+ } |
+ |
+ // Import custom CSS rules |
+ if ("personal-css" in widget.preferences) |
+ { |
+ var customRules = widget.preferences["personal-css"].split("\n"); |
+ for (var i = 0; i < customRules.length; i++) |
+ { |
+ var rule = customRules[i]; |
+ if (rule === "") |
+ continue; |
+ |
+ rule = "##" + rule; |
+ FilterStorage.addFilter(Filter.fromText(rule)); |
+ } |
+ } |
+ |
+ widget.preferences.clear(); |
} |
} |
function executeFirstRunActions() |
{ |
// Don't do anything if the user has a subscription already |
var hasSubscriptions = FilterStorage.subscriptions.some(function(subscription) {return subscription instanceof DownloadableSubscription}); |
if (hasSubscriptions) |