1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

code review, polishing

This commit is contained in:
gorhill 2015-03-06 00:36:45 -05:00
parent d376c69e2f
commit aa955ebe09
2 changed files with 9 additions and 4 deletions

View File

@ -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();
}

View File

@ -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);