From 7c46dae627c9acaa4d422eca33d7e4dd6add8ceb Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 5 Dec 2017 07:31:05 +0800 Subject: [PATCH] Fix: handle non-configurable styles --- popup/popup.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/popup/popup.js b/popup/popup.js index ddb32df1..4b2cc090 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -247,6 +247,7 @@ function createStyleElement({ Object.assign(entry, { id: ENTRY_ID_PREFIX_RAW + style.id, styleId: style.id, + styleIsUsercss: Boolean(style.usercssData), className: entry.className + ' ' + (style.enabled ? 'enabled' : 'disabled'), onmousedown: handleEvent.maybeEdit, }); @@ -277,6 +278,14 @@ function createStyleElement({ } }); + const config = $('.configure', entry); + if (!style.usercssData && style.updateUrl && style.updateUrl.includes('?') && style.url) { + config.href = style.url; + config.target = '_blank'; + } else if (!style.usercssData || !Object.keys(style.usercssData.vars || {}).length) { + config.style.display = 'none'; + } + $('.enable', entry).onclick = handleEvent.toggle; $('.disable', entry).onclick = handleEvent.toggle; $('.delete', entry).onclick = handleEvent.delete; @@ -351,8 +360,12 @@ Object.assign(handleEvent, { }, configure(event) { - const id = handleEvent.getClickedStyleId(event); - getStylesSafe({id}).then(([style]) => style).then(configDialog); + const {styleId, styleIsUsercss} = handleEvent.getClickedStyleElement(event); + if (styleIsUsercss) { + getStylesSafe({id: styleId}) + .then(([style]) => style) + .then(configDialog); + } }, indicator(event) {