From 80b5797765308c3443f4f49d8f757b0facd53a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20=C3=9Cnsalan?= Date: Wed, 24 Jul 2024 08:58:41 +0300 Subject: [PATCH] amde some fixes to assure that the older suggestion method also works --- index.html | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 3cce286..8fd12c1 100644 --- a/index.html +++ b/index.html @@ -39,6 +39,7 @@ // prettier-ignore const COMMANDS = new Map([ + ['t', { name: 'test', suggestions: [{name: 'Claude', url: 'https://claude.ai/new'}], url: 'https://chatgpt.com' }], ['a', { name: 'Chat', suggestions: ['a/claude', 'a/gemini'], url: 'https://chatgpt.com' }], ['a/claude', { url: 'https://claude.ai/new' }], ['a/gemini', { url: 'https://gemini.google.com/app' }], @@ -78,6 +79,8 @@ ], }, ], + + // Add more command entries as needed ]); */ @@ -169,17 +172,15 @@ const commands = clone.querySelector('.commands'); const commandTemplate = document.getElementById('command-template'); - for (const [key, { suggestions }] of COMMANDS.entries()) { - if (!suggestions) continue; - for (const { name, url } of suggestions) { - const clone = commandTemplate.content.cloneNode(true); - const command = clone.querySelector('.command'); - command.href = url; - if (CONFIG.openLinksInNewTab) command.target = '_blank'; - clone.querySelector('.key').innerText = key; - clone.querySelector('.name').innerText = name; - commands.append(clone); - } + for (const [key, { name, url }] of COMMANDS.entries()) { + if (!name || !url) continue; + const clone = commandTemplate.content.cloneNode(true); + const command = clone.querySelector('.command'); + command.href = url; + if (CONFIG.openLinksInNewTab) command.target = '_blank'; + clone.querySelector('.key').innerText = key; + clone.querySelector('.name').innerText = name ? name : url; + commands.append(clone); } this.shadowRoot.append(clone); @@ -522,7 +523,7 @@ const ref = clone.querySelector('.suggestion'); ref.dataset.index = index; ref.dataset.url = suggestion.url; - ref.innerText = suggestion.name; + ref.innerText = suggestion.name ? suggestion.name : suggestion; this.#suggestions.append(clone); } }