From 00257fc00e6d68f34c62715148e11190595f530c Mon Sep 17 00:00:00 2001 From: Miyashooooo Date: Tue, 3 Dec 2024 23:06:37 +0800 Subject: [PATCH] fix: add element --- index.js | 33 ++++++++++++++++++--------------- info.json | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index f8baf2b..c4f5576 100644 --- a/index.js +++ b/index.js @@ -70,21 +70,24 @@ class Plugin { } addDropDown() { - const list = document.querySelector('.extended-list-buttons'); - if (list) { - const box = document.createElement('div'); - box.className = 'select-language-box'; - const select = document.createElement('select'); - select.className = 'select-language-dropdown'; - this.supportLanguages.forEach(({ value, text }) => { - const option = document.createElement('option'); - option.value = value; - option.textContent = text; - select.append(option); - }); - box.append(select); - list.append(box); - } + const list = document.querySelectorAll('.extended-list-buttons'); + list.forEach((item) => { + const input = item.querySelector('input[data-name="language"]'); + if (input) { + const box = document.createElement('div'); + box.className = 'select-language-box'; + const select = document.createElement('select'); + select.className = 'select-language-dropdown'; + this.supportLanguages.forEach(({ value, text }) => { + const option = document.createElement('option'); + option.value = value; + option.textContent = text; + select.append(option); + }); + box.append(select); + item.append(box); + } + }) } changeEvent() { diff --git a/info.json b/info.json index 11922ab..4c0bad0 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "language", - "version": "1.0.7", + "version": "1.0.8", "description": { "zh_tw": "TREM-Lite Language Plugin" },