From e3d1c6588d5db43f3ae4444d32f842af8959cbac Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 14 Feb 2018 05:53:35 +0300 Subject: [PATCH] prefill new style name with the domain/hostname implements #344 --- edit/edit.js | 4 +++- edit/source-editor.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/edit/edit.js b/edit/edit.js index 5f78b641..9304b7fb 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -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: ''}, diff --git a/edit/source-editor.js b/edit/source-editor.js index 256e065d..324a056b 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -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