Browse Source

feat: set `data-no-icon` attribute if there's no icon

tophf 2 years ago
parent
commit
2a77dd9a18
2 changed files with 4 additions and 1 deletions
  1. 3 0
      src/common/load-script-icon.js
  2. 1 1
      src/options/views/script-item.vue

+ 3 - 0
src/common/load-script-icon.js

@@ -2,6 +2,7 @@ import { isDataUri, isHttpOrHttps, noop, sendCmdDirectly } from '@/common/index'
 
 // TODO: convert this into a component tag e.g. <safe-icon>
 const KEY = 'safeIcon';
+const KEY_DEFAULT = 'noIcon';
 
 /**
  * Sets script's safeIcon property after the image is successfully loaded
@@ -17,6 +18,8 @@ export async function loadScriptIcon(script, store, showDefault) {
     def = `${ICON_PREFIX}${isHiDPI && 128 || (script.config.removed ? 32 : 38)}.png`
   );
   if (!url || url !== script[KEY]) {
+    // exposing scripts with no icon for user's CustomCSS
+    script[KEY_DEFAULT] = def ? '' : null;
     // creates an observable property so Vue will see the change after `await`
     if (!(KEY in script)) {
       script[KEY] = null;

+ 1 - 1
src/options/views/script-item.vue

@@ -13,7 +13,7 @@
     @blur="onBlur">
     <div class="script-icon hidden-xs">
       <a :href="url" :data-hotkey="hotkeys.edit" data-hotkey-table tabIndex="-1">
-        <img :src="script.safeIcon">
+        <img :src="script.safeIcon" :data-no-icon="script.noIcon">
       </a>
     </div>
     <div class="script-name flex ml-1c">