import usercss files drag'n'dropped into the manage page
This commit is contained in:
parent
cc57d39443
commit
1273903b05
|
@ -276,7 +276,7 @@
|
||||||
data.version,
|
data.version,
|
||||||
]))
|
]))
|
||||||
).then(ok => ok &&
|
).then(ok => ok &&
|
||||||
BG.usercssHelper.save(BG.deepCopy(Object.assign(style, {reason: 'update'})))
|
BG.usercssHelper.save(BG.deepCopy(Object.assign(style, dup && {reason: 'update'})))
|
||||||
.then(r => install(deepCopy(r)))
|
.then(r => install(deepCopy(r)))
|
||||||
.catch(err => messageBox.alert(t('styleInstallFailed', err)))
|
.catch(err => messageBox.alert(t('styleInstallFailed', err)))
|
||||||
);
|
);
|
||||||
|
|
|
@ -393,6 +393,7 @@ var usercss = (() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
|
reason: 'install',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
sourceCode,
|
sourceCode,
|
||||||
sections: [],
|
sections: [],
|
||||||
|
|
|
@ -34,7 +34,17 @@ function importFromFile({fileTypeFilter, file} = {}) {
|
||||||
const fReader = new FileReader();
|
const fReader = new FileReader();
|
||||||
fReader.onloadend = event => {
|
fReader.onloadend = event => {
|
||||||
fileInput.remove();
|
fileInput.remove();
|
||||||
importFromString(event.target.result).then(numStyles => {
|
const text = event.target.result;
|
||||||
|
const maybeUsercss = !/^[\s\r\n]*\[/.test(text) &&
|
||||||
|
(text.includes('==UserStyle==') || /==UserStyle==/i.test(text));
|
||||||
|
(!maybeUsercss ?
|
||||||
|
importFromString(text) :
|
||||||
|
getOwnTab().then(tab => {
|
||||||
|
tab.url = URL.createObjectURL(new Blob([text], {type: 'text/css'}));
|
||||||
|
return BG.usercssHelper.openInstallPage(tab, {direct: true})
|
||||||
|
.then(() => URL.revokeObjectURL(tab.url));
|
||||||
|
})
|
||||||
|
).then(numStyles => {
|
||||||
document.body.style.cursor = '';
|
document.body.style.cursor = '';
|
||||||
resolve(numStyles);
|
resolve(numStyles);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user