From aa955ebe09d7e27eb38d002e4eb81383becf6d86 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 6 Mar 2015 00:36:45 -0500 Subject: [PATCH] code review, polishing --- src/js/element-picker.js | 11 ++++++++--- src/js/storage.js | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/js/element-picker.js b/src/js/element-picker.js index 8d8e5aae4..2780ba45a 100644 --- a/src/js/element-picker.js +++ b/src/js/element-picker.js @@ -483,14 +483,15 @@ var userFilterFromCandidate = function() { } // Cosmetic filter? - if ( v.slice(0, 2) === '##' ) { + if ( v.lastIndexOf('##', 0) === 0 ) { return window.location.hostname + v; } // If domain included in filter, no need for domain option - if ( v.slice(0, 2) === '||' ) { + if ( v.lastIndexOf('||', 0) === 0 ) { return v; } + // Assume net filter return v + '$domain=' + window.location.hostname; }; @@ -560,7 +561,11 @@ var onDialogClicked = function(ev) { else if ( ev.target.id === 'create' ) { var filter = userFilterFromCandidate(); if ( filter ) { - localMessager.send({ what: 'createUserFilter', filters: filter }); + var d = new Date(); + localMessager.send({ + what: 'createUserFilter', + filters: '# ' + d.toLocaleString() + ' ' + window.location.href + '\n' + filter, + }); removeElements(elementsFromFilter(taCandidate.value)); stopPicker(); } diff --git a/src/js/storage.js b/src/js/storage.js index 32142efad..0c414113c 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -129,7 +129,7 @@ if ( details.content.indexOf(content.trim()) !== -1 ) { return; } - µb.saveUserFilters(details.content.trim() + '\n' + content.trim(), onSaved); + µb.saveUserFilters(details.content.trim() + '\n\n' + content.trim(), onSaved); }; this.loadUserFilters(onLoaded);