diff options
author | gorhill <rhill@raymondhill.net> | 2015-01-06 12:14:37 -0500 |
---|---|---|
committer | gorhill <rhill@raymondhill.net> | 2015-01-06 12:14:37 -0500 |
commit | 4b9fc6d6f5b8c42a7b7e700b076a93d355c4f32c (patch) | |
tree | 29a4ad55f9aad5f0f3a8be582480f576b752f18b | |
parent | 5e8b540669948f52bc656e1ade679d2ade26bf41 (diff) | |
download | uBlock-4b9fc6d6f5b8c42a7b7e700b076a93d355c4f32c.zip uBlock-4b9fc6d6f5b8c42a7b7e700b076a93d355c4f32c.tar.gz uBlock-4b9fc6d6f5b8c42a7b7e700b076a93d355c4f32c.tar.bz2 |
fixed import/export of dynamic rules
-rw-r--r-- | src/_locales/en/messages.json | 14 | ||||
-rw-r--r-- | src/js/dyna-rules.js | 20 |
2 files changed, 18 insertions, 16 deletions
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 3f58f4f..77d4f2a 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -320,8 +320,8 @@ "description":"English: Export" }, "1pExportFilename" : { - "message": "ublock-custom-filters_{{datetime}}.txt", - "description": "English: ublock-custom-filters_{{datetime}}.txt" + "message": "my-ublock-static-filters_{{datetime}}.txt", + "description": "English: my-ublock-static-filters_{{datetime}}.txt" }, "1pApplyChanges":{ "message":"Apply changes", @@ -348,7 +348,7 @@ "description": "" }, "rulesDefaultFileName": { - "message": "my-ublock-dynamic-rules.txt", + "message": "my-ublock-dynamic-rules_{{datetime}}.txt", "description": "default file name to use" }, "whitelistPrompt":{ @@ -364,8 +364,8 @@ "description":"English: Export" }, "whitelistExportFilename" : { - "message": "ublock-whitelist_{{datetime}}.txt", - "description": "English: ublock-whitelist_{{datetime}}.txt" + "message": "my-ublock-whitelist_{{datetime}}.txt", + "description": "English: my-ublock-whitelist_{{datetime}}.txt" }, "whitelistApply":{ "message":"Apply changes", @@ -432,8 +432,8 @@ "description": "English: Backup to file" }, "aboutBackupFilename" : { - "message": "ublock-backup_{{datetime}}.txt", - "description": "English: ublock-backup_{{datetime}}.txt" + "message": "my-ublock-backup_{{datetime}}.txt", + "description": "English: my-ublock-backup_{{datetime}}.txt" }, "aboutRestoreDataButton" : { "message": "Restore from file...", diff --git a/src/js/dyna-rules.js b/src/js/dyna-rules.js index 52370b2..7c11fc5 100644 --- a/src/js/dyna-rules.js +++ b/src/js/dyna-rules.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uMatrix */ -/* global chrome, messaging, uDom */ +/* global vAPI, uDom */ /******************************************************************************/ @@ -97,11 +97,9 @@ function handleImportFilePicker() { if ( typeof this.result !== 'string' || this.result === '' ) { return; } - var request = { - 'what': 'setDynamicRules', - 'rawRules': uDom('#rulesEditor').val() - }; - messager.send(request, processRules); + var textarea = uDom('#rulesEditor'); + textarea.val([textarea.val(), this.result].join('\n').trim()); + rulesChanged(); }; var file = this.files[0]; if ( file === undefined || file.name === '' ) { @@ -129,9 +127,13 @@ var startImportFilePicker = function() { /******************************************************************************/ function exportUserRulesToFile() { - chrome.downloads.download({ - 'url': 'data:text/plain,' + encodeURIComponent(rulesFromHTML('#diff .left li')), - 'filename': uDom('[data-i18n="userRulesDefaultFileName"]').text(), + var now = new Date(); + var filename = vAPI.i18n('rulesDefaultFileName') + .replace('{{datetime}}', now.toLocaleString()) + .replace(/ +/g, '_'); + vAPI.download({ + 'url': 'data:text/plain,' + encodeURIComponent(uDom('#rulesEditor').val()), + 'filename': filename, 'saveAs': true }); } |