prefill new style name with the domain/hostname

implements #344
This commit is contained in:
tophf 2018-02-14 05:53:35 +03:00
parent c1b47e4b23
commit e3d1c6588d
2 changed files with 7 additions and 2 deletions

View File

@ -225,7 +225,9 @@ function initStyleData() {
const id = params.get('id');
const createEmptyStyle = () => ({
id: null,
name: '',
name: params.get('domain') ||
tryCatch(() => new URL(params.get('url-prefix')).hostname) ||
'',
enabled: true,
sections: [
Object.assign({code: ''},

View File

@ -106,7 +106,10 @@ function createSourceEditor(style) {
}
const DEFAULT_CODE = `
/* ==UserStyle==
@name ${t('usercssReplaceTemplateName') + ' - ' + new Date().toLocaleString()}
@name ${
style.name ||
t('usercssReplaceTemplateName') + ' - ' + new Date().toLocaleString()
}
@namespace github.com/openstyles/stylus
@version 0.1.0
@description A new userstyle