mirror of https://github.com/gorhill/uBlock.git
file picker is gone: generate a unique filename each time
This commit is contained in:
parent
3ba151e89d
commit
52e8cb5338
|
@ -20,12 +20,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global vAPI, uDom */
|
/* global vAPI, uDom */
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var cachedUserFilters = '';
|
var cachedUserFilters = '';
|
||||||
|
@ -67,7 +68,7 @@ function allFiltersApplyHandler() {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
function handleImportFilePicker() {
|
var handleImportFilePicker = function() {
|
||||||
var fileReaderOnLoadHandler = function() {
|
var fileReaderOnLoadHandler = function() {
|
||||||
var textarea = uDom('#userFilters');
|
var textarea = uDom('#userFilters');
|
||||||
textarea.val([textarea.val(), this.result].join('\n').trim());
|
textarea.val([textarea.val(), this.result].join('\n').trim());
|
||||||
|
@ -83,7 +84,7 @@ function handleImportFilePicker() {
|
||||||
var fr = new FileReader();
|
var fr = new FileReader();
|
||||||
fr.onload = fileReaderOnLoadHandler;
|
fr.onload = fileReaderOnLoadHandler;
|
||||||
fr.readAsText(file);
|
fr.readAsText(file);
|
||||||
}
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -98,20 +99,21 @@ var startImportFilePicker = function() {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
function exportUserFiltersToFile() {
|
var exportUserFiltersToFile = function() {
|
||||||
var val = uDom('#userFilters').val().trim();
|
var val = uDom('#userFilters').val().trim();
|
||||||
|
if ( val === '' ) {
|
||||||
if (val) {
|
return;
|
||||||
vAPI.download({
|
|
||||||
'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(val),
|
|
||||||
'filename': 'my-ublock-filters.txt'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
var now = new Date();
|
||||||
|
vAPI.download({
|
||||||
|
'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(val),
|
||||||
|
'filename': 'ublock-filters_' + now.toLocaleString().replace(/ +/g, '_') + '.txt'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
function userFiltersApplyHandler() {
|
var userFiltersApplyHandler = function() {
|
||||||
var onWritten = function(details) {
|
var onWritten = function(details) {
|
||||||
if ( details.error ) {
|
if ( details.error ) {
|
||||||
return;
|
return;
|
||||||
|
@ -125,7 +127,7 @@ function userFiltersApplyHandler() {
|
||||||
content: uDom('#userFilters').val()
|
content: uDom('#userFilters').val()
|
||||||
};
|
};
|
||||||
messager.send(request, onWritten);
|
messager.send(request, onWritten);
|
||||||
}
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,14 @@
|
||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global µBlock, uDom */
|
/* global vAPI, uDom */
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
uDom.onLoad(function() {
|
uDom.onLoad(function() {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var messager = vAPI.messaging.channel('about.js');
|
var messager = vAPI.messaging.channel('about.js');
|
||||||
|
@ -37,10 +38,10 @@ var exportToFile = function() {
|
||||||
if (!userData) {
|
if (!userData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var now = new Date();
|
||||||
vAPI.download({
|
vAPI.download({
|
||||||
'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(userData)),
|
'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(userData)),
|
||||||
'filename': 'ublock-backup.txt'
|
'filename': 'ublock-backup_' + now.toLocaleString().replace(/ +/g, '_') + '.txt'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global vAPI, uDom */
|
/* global vAPI, uDom */
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var messager = vAPI.messaging.channel('whitelist.js');
|
var messager = vAPI.messaging.channel('whitelist.js');
|
||||||
|
@ -94,13 +95,14 @@ var startImportFilePicker = function() {
|
||||||
|
|
||||||
var exportWhitelistToFile = function() {
|
var exportWhitelistToFile = function() {
|
||||||
var val = uDom('#whitelist').val().trim();
|
var val = uDom('#whitelist').val().trim();
|
||||||
|
if ( val === '' ) {
|
||||||
if (val) {
|
return;
|
||||||
vAPI.download({
|
|
||||||
'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(val),
|
|
||||||
'filename': 'my-ublock-whitelist.txt'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
var now = new Date();
|
||||||
|
vAPI.download({
|
||||||
|
'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(val),
|
||||||
|
'filename': 'ublock-whitelist_' + now.toLocaleString().replace(/ +/g, '_') + '.txt'
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue