mirror of https://github.com/gorhill/uBlock.git
this fixes #1022
This commit is contained in:
parent
eee7c29abe
commit
fd1ccebf41
|
@ -143,17 +143,22 @@ var exportUserFiltersToFile = function() {
|
|||
/******************************************************************************/
|
||||
|
||||
var applyChanges = function() {
|
||||
var textarea = uDom.nodeFromId('userFilters');
|
||||
|
||||
var onWritten = function(details) {
|
||||
if ( details.error ) {
|
||||
return;
|
||||
}
|
||||
textarea.value = details.content;
|
||||
cachedUserFilters = details.content.trim();
|
||||
userFiltersChanged();
|
||||
allFiltersApplyHandler();
|
||||
textarea.focus();
|
||||
};
|
||||
|
||||
var request = {
|
||||
what: 'writeUserFilters',
|
||||
content: uDom('#userFilters').val()
|
||||
content: textarea.value
|
||||
};
|
||||
messager.send(request, onWritten);
|
||||
};
|
||||
|
|
|
@ -862,10 +862,10 @@ var onMessage = function(request, sender, callback) {
|
|||
// Async
|
||||
switch ( request.what ) {
|
||||
case 'readUserFilters':
|
||||
return µb.assets.get(µb.userFiltersPath, callback);
|
||||
return µb.loadUserFilters(callback);
|
||||
|
||||
case 'writeUserFilters':
|
||||
return µb.assets.put(µb.userFiltersPath, request.content, callback);
|
||||
return µb.saveUserFilters(request.content, callback);
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -151,6 +151,12 @@
|
|||
/******************************************************************************/
|
||||
|
||||
µBlock.saveUserFilters = function(content, callback) {
|
||||
// https://github.com/gorhill/uBlock/issues/1022
|
||||
// Be sure to end with an empty line.
|
||||
content = content.trim();
|
||||
if ( content !== '' ) {
|
||||
content += '\n';
|
||||
}
|
||||
this.assets.put(this.userFiltersPath, content, callback);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue