This commit is contained in:
parent
fb45e86648
commit
ac967ace5e
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
var STYLISH_DUMP_FILE_EXT = '.txt';
|
var STYLISH_DUMP_FILE_EXT = '.txt';
|
||||||
var STYLISH_DUMPFILE_EXTENSION = '.json';
|
var STYLISH_DUMPFILE_EXTENSION = '.json';
|
||||||
var STYLISH_DEFAULT_SAVE_NAME = 'stylus-mm-dd-yyy' + STYLISH_DUMP_FILE_EXT;
|
var STYLISH_DEFAULT_SAVE_NAME = 'stylus-mm-dd-yyyy' + STYLISH_DUMP_FILE_EXT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* !!works only when page has representation - backgound page won't work
|
* !!works only when page has representation - backgound page won't work
|
||||||
|
@ -58,10 +58,16 @@ document.getElementById('file-all-styles').addEventListener('click', function ()
|
||||||
let text = JSON.stringify(styles);
|
let text = JSON.stringify(styles);
|
||||||
let fileName = generateFileName() || STYLISH_DEFAULT_SAVE_NAME;
|
let fileName = generateFileName() || STYLISH_DEFAULT_SAVE_NAME;
|
||||||
|
|
||||||
let a = document.createElement('a');
|
let url = 'data:text/plain;charset=utf-8,' + encodeURIComponent(text);
|
||||||
a.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(text);
|
// for long URLs; https://github.com/schomery/stylish-chrome/issues/13#issuecomment-284582600
|
||||||
a.setAttribute('download', fileName);
|
fetch(url)
|
||||||
a.dispatchEvent(new MouseEvent('click'));
|
.then(res => res.blob())
|
||||||
|
.then(blob => {
|
||||||
|
let a = document.createElement('a');
|
||||||
|
a.setAttribute('download', fileName);
|
||||||
|
a.setAttribute('href', URL.createObjectURL(blob));
|
||||||
|
a.dispatchEvent(new MouseEvent('click'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user