From ca226add4d65d39eba1aa262d32fe63b5e8efdc7 Mon Sep 17 00:00:00 2001 From: Gemorroj Date: Mon, 29 Jul 2013 12:01:51 +0300 Subject: [PATCH] fix empty rules --- includes/noads-options.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/noads-options.js b/includes/noads-options.js index 05d7f22..13ad158 100644 --- a/includes/noads-options.js +++ b/includes/noads-options.js @@ -213,7 +213,7 @@ var options = { } } tmp = null; - return rez.length ? new RegExp(rez.join('|'),'mi') : false; + return rez.length ? new RegExp(rez.join('|'), 'mi') : false; }, getRawRules: function (name, domain, global) { @@ -340,9 +340,13 @@ var options = { try { var reader = new FileReader(); reader.onload = function (e) { - whitelist = JSON.parse(e.target.result); - setValue('noads_scriptlist_white', '@@||' + whitelist.allowsites.join('^\n@@||') + '^\n@@==' + whitelist.allowscripts.join('\n@@==')); - setValue('noads_scriptlist', '##$$' + whitelist.blockregexps.join('^\n##$$')); + var whitelist = JSON.parse(e.target.result); + if (whitelist.allowsites.length > 0 || whitelist.allowscripts.length > 0) { + setValue('noads_scriptlist_white', '@@||' + whitelist.allowsites.join('^\n@@||') + '^\n@@==' + whitelist.allowscripts.join('\n@@==')); + } + if (whitelist.blockregexps.length > 0) { + setValue('noads_scriptlist', '##$$' + whitelist.blockregexps.join('^\n##$$')); + } }; reader.readAsText(opera.extension.getFile('/scriptrules.json')); } catch (bug) {