From f8f9a1b522cd94f627dfd523506582a8a09db8ca Mon Sep 17 00:00:00 2001 From: Kajitsy Date: Fri, 26 Jan 2024 23:18:01 +0300 Subject: [PATCH] 2.2.4.4 Update --- chromium/_locales/en/messages.json | 12 +- chromium/_locales/es/messages.json | 12 +- chromium/_locales/jp/messages.json | 10 +- chromium/_locales/ru/messages.json | 12 +- chromium/manifest.json | 7 +- chromium/onlyGi.html | 117 --------------- chromium/onlyGi.js | 69 --------- chromium/onlyHsr.html | 118 ---------------- chromium/onlyHsr.js | 67 --------- chromium/options.js | 6 + chromium/options_background.js | 30 ---- chromium/popup.html | 45 +++--- chromium/popup.js | 220 ++++++++++++++++++++++------- chromium/script_imports.js | 5 - firefox/_locales/en/messages.json | 12 +- firefox/_locales/es/messages.json | 12 +- firefox/_locales/jp/messages.json | 10 +- firefox/_locales/ru/messages.json | 12 +- firefox/manifest.json | 6 +- firefox/onlyGi.html | 117 --------------- firefox/onlyGi.js | 66 --------- firefox/onlyHsr.html | 118 ---------------- firefox/onlyHsr.js | 64 --------- firefox/options.js | 6 + firefox/options_background.js | 23 --- firefox/popup.html | 45 +++--- firefox/popup.js | 220 ++++++++++++++++++++++------- 27 files changed, 485 insertions(+), 956 deletions(-) delete mode 100644 chromium/onlyGi.html delete mode 100644 chromium/onlyGi.js delete mode 100644 chromium/onlyHsr.html delete mode 100644 chromium/onlyHsr.js delete mode 100644 chromium/options_background.js delete mode 100644 chromium/script_imports.js delete mode 100644 firefox/onlyGi.html delete mode 100644 firefox/onlyGi.js delete mode 100644 firefox/onlyHsr.html delete mode 100644 firefox/onlyHsr.js delete mode 100644 firefox/options_background.js diff --git a/chromium/_locales/en/messages.json b/chromium/_locales/en/messages.json index 860d6c8..b330faf 100644 --- a/chromium/_locales/en/messages.json +++ b/chromium/_locales/en/messages.json @@ -1,11 +1,17 @@ { "extensionDescription": { - "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.4" + "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.4.4" }, - "submit": { + "sthsr": { "message": "Submit" }, - "share": { + "stgi": { + "message": "Submit" + }, + "sehsr": { + "message": "Share" + }, + "segi": { "message": "Share" }, "labelgi": { diff --git a/chromium/_locales/es/messages.json b/chromium/_locales/es/messages.json index bfed1ee..ecac72c 100644 --- a/chromium/_locales/es/messages.json +++ b/chromium/_locales/es/messages.json @@ -1,14 +1,20 @@ { "extensionDescription": { - "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.4" + "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.4.4" }, - "submit": { + "sthsr": { "message": "Enviar" }, + "stgi": { + "message": "Enviar" + }, + "sehsr": { + "message": "Compartir" + }, "share": { "message": "Compartir" }, - "labelgi": { + "segi": { "message": "Solo Genshin Impact" }, "labelHsr": { diff --git a/chromium/_locales/jp/messages.json b/chromium/_locales/jp/messages.json index fefedb5..515283b 100644 --- a/chromium/_locales/jp/messages.json +++ b/chromium/_locales/jp/messages.json @@ -1,8 +1,14 @@ { - "submit": { + "sthsr": { "message": "送信" }, - "share": { + "stgi": { + "message": "送信" + }, + "sehsr": { + "message": "共有" + }, + "segi": { "message": "共有" }, "labelgi": { diff --git a/chromium/_locales/ru/messages.json b/chromium/_locales/ru/messages.json index 7a4538d..6032caf 100644 --- a/chromium/_locales/ru/messages.json +++ b/chromium/_locales/ru/messages.json @@ -1,11 +1,17 @@ { "extensionDescription": { - "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.4" + "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.4.4" }, - "submit": { + "sthsr": { "message": "Ввести" }, - "share": { + "stgi": { + "message": "Ввести" + }, + "sehsr": { + "message": "Поделиться" + }, + "segi": { "message": "Поделиться" }, "labelGi": { diff --git a/chromium/manifest.json b/chromium/manifest.json index 93a7acc..b18ca03 100644 --- a/chromium/manifest.json +++ b/chromium/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Genshin/Star Rail CodeEntter", - "version": "2.2.4", + "version": "2.2.4.4", "description": "__MSG_extensionDescription__", "default_locale": "en", "icons": { @@ -20,13 +20,14 @@ ], "action": { "default_icon": "/pictures/icon.png", - "default_title": "CodeEntter" + "default_title": "CodeEntter", + "default_popup": "popup.html" }, "options_ui": { "page": "options.html", "open_in_tab": false }, "background": { - "service_worker": "script_imports.js" + "service_worker": "dailychecker.js" } } diff --git a/chromium/onlyGi.html b/chromium/onlyGi.html deleted file mode 100644 index c1f2604..0000000 --- a/chromium/onlyGi.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - -
- -
-
- - -
- -
- - - - \ No newline at end of file diff --git a/chromium/onlyGi.js b/chromium/onlyGi.js deleted file mode 100644 index 2b422b8..0000000 --- a/chromium/onlyGi.js +++ /dev/null @@ -1,69 +0,0 @@ -if (typeof browser === "undefined") { - browser = chrome; -} -function displayOverlay() { - overlay.textContent = browser.i18n.getMessage("displayOverlay") - overlay.style.display = 'flex'; - setTimeout(() => { - overlay.style.display = 'none'; - }, 2000); -} -const buttonIds = ['submit', 'share']; -const frame = document.getElementById('frame'); -const codeElement = document.getElementById('code'); -const overlay = document.getElementById('displayOverlay'); - -buttonIds.forEach((buttonId) => { - const buttonElement = document.getElementById(buttonId); - if (buttonElement) { - buttonElement.textContent = browser.i18n.getMessage(buttonId); - buttonElement.addEventListener('click', () => { - const code = codeElement.value; - const locales = navigator.language.slice(0, 2); - let url; - switch (buttonId) { - case 'submit': - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - break; - case 'share': - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - default: - break; - } - if (buttonId === 'submit') { - frame.src = url; - frame.style.display = 'block'; - codeElement.style.display = 'none'; - buttonIds.forEach((id) => { - document.getElementById(id).style.display = 'none'; - }); - } - }); - } -}); -browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then((result) => { - if (result.buttonColorGi) { - document.documentElement.style.setProperty('--button-color', result.buttonColorGi); - } - if (result.buttonTextColorGi) { - document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorGi); - } - if (result.BackgroundGi) { - document.body.style.background = '#4e4b54'; - document.body.style.background = result.BackgroundColorGi; - } - else { - document.body.style.background = 'url("/pictures/backgroundGI.png")'; - document.body.style.backgroundSize = 'cover'; - document.body.style.backgroundRepeat = 'no-repeat'; - document.body.style.backgroundPosition = 'center'; - document.body.style.overflow = 'hidden'; - } -}); - -browser.storage.local.get(['roundingDisable']).then((result) => { - document.documentElement.style.setProperty('--border-radius', result.roundingDisable ? '10px' : '20px'); -}); \ No newline at end of file diff --git a/chromium/onlyHsr.html b/chromium/onlyHsr.html deleted file mode 100644 index 9b8ac8e..0000000 --- a/chromium/onlyHsr.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - -
- -
-
- - -
- -
- - - - \ No newline at end of file diff --git a/chromium/onlyHsr.js b/chromium/onlyHsr.js deleted file mode 100644 index 3aa96c0..0000000 --- a/chromium/onlyHsr.js +++ /dev/null @@ -1,67 +0,0 @@ -if (typeof browser === "undefined") { - browser = chrome; -} -function displayOverlay() { - overlay.textContent = browser.i18n.getMessage("displayOverlay") - overlay.style.display = 'flex'; - setTimeout(() => { - overlay.style.display = 'none'; - }, 2000); -} -const buttonIds = ['submit', 'share']; -const frame = document.getElementById('frame'); -const codeElement = document.getElementById('code'); -const overlay = document.getElementById('displayOverlay'); - -buttonIds.forEach((buttonId) => { - const buttonElement = document.getElementById(buttonId); - if (buttonElement) { - buttonElement.textContent = browser.i18n.getMessage(buttonId); - buttonElement.addEventListener('click', () => { - const code = codeElement.value; - let url; - switch (buttonId) { - case 'submit': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - break; - case 'share': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - default: - break; - } - if (buttonId === 'submit') { - frame.src = url; - frame.style.display = 'block'; - codeElement.style.display = 'none'; - buttonIds.forEach((id) => { - document.getElementById(id).style.display = 'none'; - }); - } - }); - } -}); -browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then((result) => { - if (result.buttonColorHsr) { - document.documentElement.style.setProperty('--button-color', result.buttonColorHsr); - } - if (result.buttonTextColorHsr) { - document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorHsr); - } - if (result.BackgroundHsr) { - document.body.style.background = '#1e274e'; - document.body.style.background = result.BackgroundColorHsr; - } - else { - document.body.style.background = 'url("/pictures/backgroundHSR.png")'; - document.body.style.backgroundSize = 'cover'; - document.body.style.backgroundRepeat = 'no-repeat'; - document.body.style.backgroundPosition = 'center'; - document.body.style.overflow = 'hidden'; - } -}); -browser.storage.local.get(['roundingDisable']).then((result) => { - document.documentElement.style.setProperty('--border-radius', result.roundingDisable ? '10px' : '20px'); -}); \ No newline at end of file diff --git a/chromium/options.js b/chromium/options.js index 5785107..18d8877 100644 --- a/chromium/options.js +++ b/chromium/options.js @@ -223,4 +223,10 @@ browser.storage.local.get(['iconDisable','roundingDisable', 'snowDisable', 'Back element.value = elements[id]; } } + if (result.buttonColorGi & result.buttonColorHsr) { + } else if (result.buttonColorHsr) {} + else if (result.buttonColorGi) {} + else { + browser.storage.local.set({buttonColorGi: '#a89f96', buttonColorHsr: '#004080'}) + } }); \ No newline at end of file diff --git a/chromium/options_background.js b/chromium/options_background.js deleted file mode 100644 index 83c165f..0000000 --- a/chromium/options_background.js +++ /dev/null @@ -1,30 +0,0 @@ -if (typeof browser === "undefined") { - browser = chrome; - browser.browserAction = chrome.action; -} -async function updatePopup() { - const resultGi = await browser.storage.local.get('onlyGi'); - const resultHsr = await browser.storage.local.get('onlyHsr'); - - if (resultGi.onlyGi) { - browser.browserAction.setPopup({ - popup: 'onlyGi.html' - }); - } else if (resultHsr.onlyHsr) { - browser.browserAction.setPopup({ - popup: 'onlyHsr.html' - }); - } else { - browser.browserAction.setPopup({ - popup: 'popup.html' - }); - } -} - -browser.storage.onChanged.addListener(async function(changes, areaName) { - if (areaName === 'local' && ('onlyGi' in changes || 'onlyHsr' in changes)) { - await updatePopup(); - } -}); - -updatePopup(); \ No newline at end of file diff --git a/chromium/popup.html b/chromium/popup.html index 314d807..8de5836 100644 --- a/chromium/popup.html +++ b/chromium/popup.html @@ -9,10 +9,6 @@ --input-color: rgba(0, 0, 0, 0.5); --input-text-color: white; } - @font-face { - font-family: 'SDK_SC_Web'; - src: url('GIfont.woff2') format('woff2'); - } body { font-family: var(--); padding: 10px; @@ -21,6 +17,8 @@ background-position: center; overflow: hidden; background-image: url(./pictures/background.png); + max-height: 560px; + min-width: 300px; } #input-container { display: flex; @@ -45,10 +43,6 @@ display: flex; justify-content: space-between; } - #submitGI, #submitHSR, #shareGI, #shareHSR { - width: 48%; - margin-top: 10px; - } button { cursor: pointer; display: flex; @@ -63,8 +57,10 @@ z-index: 2; font-family: 'SDK_SC_Web'; box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.5); + width: 48%; + margin-top: 10px; } - #submitGI:hover, #submitHSR:hover, #shareGI:hover, #shareHSR:hover, #options:hover { + button:hover { transform: scale(1.05); border-radius: 10px; display: flex; @@ -90,6 +86,9 @@ z-index: 2; font-family: 'SDK_SC_Web'; } + #hsr-popup, #gi-popup { + display: none; + } @keyframes snowfall { from { transform: translateY(-100vh); @@ -106,16 +105,30 @@
-
- - +
+
+ + +
+
+ + +
-
- - +
+
+ + +
+
+
+
+ + +
-
+ diff --git a/chromium/popup.js b/chromium/popup.js index 2dfa3c9..91d8a26 100644 --- a/chromium/popup.js +++ b/chromium/popup.js @@ -1,52 +1,13 @@ if (typeof browser === "undefined") { browser = chrome; } -const buttonIds = ['submitGI', 'shareGI', 'submitHSR', 'shareHSR']; +const buttonIds = ['submitGI', 'shareGI', 'submitHSR', 'shareHSR', 'sthsr', 'sehsr', 'stgi', 'segi']; const frame = document.getElementById('frame'); const codeElement = document.getElementById('code'); const overlay = document.getElementById('displayOverlay'); - -buttonIds.forEach((buttonId) => { - const buttonElement = document.getElementById(buttonId); - if (buttonElement) { - buttonElement.textContent = browser.i18n.getMessage(buttonId); - buttonElement.addEventListener('click', () => { - const code = codeElement.value; - const locales = navigator.language.slice(0, 2); - let url; - switch (buttonId) { - case 'submitGI': - document.body.style.backgroundImage = "url(/pictures/backgroundGI.png)"; - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - break; - case 'submitHSR': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - document.body.style.backgroundImage = "url(/pictures/backgroundHSR.png)"; - break; - case 'shareGI': - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - case 'shareHSR': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - default: - break; - } - if (buttonId === 'submitGI' || buttonId === 'submitHSR') { - frame.src = url; - frame.style.display = 'block'; - codeElement.style.display = 'none'; - buttonIds.forEach((id) => { - document.getElementById(id).style.display = 'none'; - }); - } - }); - } -}); +const font = document.styleSheets[0]; +const HSRfont = "@font-face {font-family: 'SDK_SC_Web'; src: url('HSRfont.woff2') format('woff2');}"; +const GIfont = "@font-face {font-family: 'SDK_SC_Web'; src: url('GIfont.woff2') format('woff2');}"; function displayOverlay() { overlay.textContent = browser.i18n.getMessage("displayOverlay") overlay.style.display = 'flex'; @@ -54,14 +15,171 @@ function displayOverlay() { overlay.style.display = 'none'; }, 2000); } -browser.storage.local.get(['buttonColorMain', 'buttonTextColorMain']).then((result) => { - if (result.buttonColorMain) { - document.documentElement.style.setProperty('--button-color', result.buttonColorMain); - } - if (result.buttonTextColorMain) { - document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorMain); +browser.storage.local.get(['onlyHsr', 'onlyGi']).then(function (result) { + if (result.onlyHsr) { + font.insertRule(HSRfont, font.cssRules.length); + document.getElementById("main-popup").style.display = "none"; + document.getElementById("hsr-popup").style.display = "block"; + buttonIds.forEach((buttonId) => { + const buttonElement = document.getElementById(buttonId); + if (buttonElement) { + buttonElement.textContent = browser.i18n.getMessage(buttonId); + buttonElement.addEventListener('click', () => { + const code = codeElement.value; + let url; + switch (buttonId) { + case 'sthsr': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + break; + case 'sehsr': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + default: + break; + } + if (buttonId === 'sthsr') { + frame.src = url; + frame.style.display = 'block'; + codeElement.style.display = 'none'; + buttonIds.forEach((id) => { + document.getElementById(id).style.display = 'none'; + }); + } + }); + } + }) + browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then((result) => { + if (result.buttonColorHsr) { + document.documentElement.style.setProperty('--button-color', result.buttonColorHsr); + } + if (result.buttonTextColorHsr) { + document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorHsr); + } + if (result.BackgroundHsr) { + document.body.style.background = '#1e274e'; + document.body.style.background = result.BackgroundColorHsr; + } + else { + document.documentElement.style.setProperty('--button-text-color', '#ffffff'); + document.documentElement.style.setProperty('--button-color', '#004080'); + document.body.style.background = 'url("/pictures/backgroundHSR.png")'; + document.body.style.backgroundSize = 'cover'; + document.body.style.backgroundRepeat = 'no-repeat'; + document.body.style.backgroundPosition = 'center'; + document.body.style.overflow = 'hidden'; + } + }); + } else if (result.onlyGi) { + font.insertRule(GIfont, font.cssRules.length); + document.getElementById("main-popup").style.display = "none"; + document.getElementById("gi-popup").style.display = "block"; + buttonIds.forEach((buttonId) => { + const buttonElement = document.getElementById(buttonId); + if (buttonElement) { + buttonElement.textContent = browser.i18n.getMessage(buttonId); + buttonElement.addEventListener('click', () => { + const code = codeElement.value; + const locales = navigator.language.slice(0, 2); + let url; + switch (buttonId) { + case 'stgi': + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + break; + case 'segi': + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + default: + break; + } + if (buttonId === 'stgi') { + frame.src = url; + frame.style.display = 'block'; + codeElement.style.display = 'none'; + buttonIds.forEach((id) => { + document.getElementById(id).style.display = 'none'; + }); + } + }); + } + }); + browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then((result) => { + if (result.buttonColorGi) { + document.documentElement.style.setProperty('--button-color', result.buttonColorGi); + } + if (result.buttonTextColorGi) { + document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorGi); + } + if (result.BackgroundGi) { + document.body.style.background = '#4e4b54'; + document.body.style.background = result.BackgroundColorGi; + } + else { + document.documentElement.style.setProperty('--button-text-color', '#ffffff'); + document.documentElement.style.setProperty('--button-color', '#a89f96'); + document.body.style.background = 'url("/pictures/backgroundGI.png")'; + document.body.style.backgroundSize = 'cover'; + document.body.style.backgroundRepeat = 'no-repeat'; + document.body.style.backgroundPosition = 'center'; + document.body.style.overflow = 'hidden'; + } + }); + } else { + font.insertRule(GIfont, font.cssRules.length); + buttonIds.forEach((buttonId) => { + const buttonElement = document.getElementById(buttonId); + buttonElement.textContent = browser.i18n.getMessage(buttonId); + if (buttonElement) { + buttonElement.addEventListener('click', () => { + const code = codeElement.value; + const locales = navigator.language.slice(0, 2); + let url; + switch (buttonId) { + case 'submitGI': + document.body.style.backgroundImage = "url(/pictures/backgroundGI.png)"; + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + break; + case 'submitHSR': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + document.body.style.backgroundImage = "url(/pictures/backgroundHSR.png)"; + break; + case 'shareGI': + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + case 'shareHSR': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + default: + break; + } + if (buttonId === 'submitGI' || buttonId === 'submitHSR') { + frame.src = url; + frame.style.display = 'block'; + codeElement.style.display = 'none'; + buttonIds.forEach((id) => { + document.getElementById(id).style.display = 'none'; + }); + } + }); + } + }); + browser.storage.local.get(['buttonColorMain', 'buttonTextColorMain']).then((result) => { + if (result.buttonColorMain) { + document.documentElement.style.setProperty('--button-color', result.buttonColorMain); + } + if (result.buttonTextColorMain) { + document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorMain); + } + }); } -}); +}) browser.storage.local.get(['roundingDisable']).then((result) => { document.documentElement.style.setProperty('--border-radius', result.roundingDisable ? '10px' : '20px'); -}); \ No newline at end of file +}); diff --git a/chromium/script_imports.js b/chromium/script_imports.js deleted file mode 100644 index 95f82ed..0000000 --- a/chromium/script_imports.js +++ /dev/null @@ -1,5 +0,0 @@ -try { - importScripts("options_background.js", "dailychecker.js"); - } catch (e) { - console.log(e); - } \ No newline at end of file diff --git a/firefox/_locales/en/messages.json b/firefox/_locales/en/messages.json index 860d6c8..b330faf 100644 --- a/firefox/_locales/en/messages.json +++ b/firefox/_locales/en/messages.json @@ -1,11 +1,17 @@ { "extensionDescription": { - "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.4" + "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.4.4" }, - "submit": { + "sthsr": { "message": "Submit" }, - "share": { + "stgi": { + "message": "Submit" + }, + "sehsr": { + "message": "Share" + }, + "segi": { "message": "Share" }, "labelgi": { diff --git a/firefox/_locales/es/messages.json b/firefox/_locales/es/messages.json index bfed1ee..ecac72c 100644 --- a/firefox/_locales/es/messages.json +++ b/firefox/_locales/es/messages.json @@ -1,14 +1,20 @@ { "extensionDescription": { - "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.4" + "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.4.4" }, - "submit": { + "sthsr": { "message": "Enviar" }, + "stgi": { + "message": "Enviar" + }, + "sehsr": { + "message": "Compartir" + }, "share": { "message": "Compartir" }, - "labelgi": { + "segi": { "message": "Solo Genshin Impact" }, "labelHsr": { diff --git a/firefox/_locales/jp/messages.json b/firefox/_locales/jp/messages.json index fefedb5..515283b 100644 --- a/firefox/_locales/jp/messages.json +++ b/firefox/_locales/jp/messages.json @@ -1,8 +1,14 @@ { - "submit": { + "sthsr": { "message": "送信" }, - "share": { + "stgi": { + "message": "送信" + }, + "sehsr": { + "message": "共有" + }, + "segi": { "message": "共有" }, "labelgi": { diff --git a/firefox/_locales/ru/messages.json b/firefox/_locales/ru/messages.json index 7a4538d..6032caf 100644 --- a/firefox/_locales/ru/messages.json +++ b/firefox/_locales/ru/messages.json @@ -1,11 +1,17 @@ { "extensionDescription": { - "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.4" + "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.4.4" }, - "submit": { + "sthsr": { "message": "Ввести" }, - "share": { + "stgi": { + "message": "Ввести" + }, + "sehsr": { + "message": "Поделиться" + }, + "segi": { "message": "Поделиться" }, "labelGi": { diff --git a/firefox/manifest.json b/firefox/manifest.json index c85c60b..3f1f6f5 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Genshin/Star Rail CodeEntter", - "version": "2.2.4", + "version": "2.2.4.4", "description": "__MSG_extensionDescription__", "default_locale": "en", "icons": { @@ -18,7 +18,8 @@ ], "browser_action": { "default_icon": "/pictures/icon.png", - "default_title": "CodeEntter" + "default_title": "CodeEntter", + "default_popup": "popup.html" }, "options_ui": { "page": "options.html", @@ -26,7 +27,6 @@ }, "background": { "scripts": [ - "options_background.js", "dailychecker.js" ] } diff --git a/firefox/onlyGi.html b/firefox/onlyGi.html deleted file mode 100644 index c1f2604..0000000 --- a/firefox/onlyGi.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - -
- -
-
- - -
- -
- - - - \ No newline at end of file diff --git a/firefox/onlyGi.js b/firefox/onlyGi.js deleted file mode 100644 index 572e885..0000000 --- a/firefox/onlyGi.js +++ /dev/null @@ -1,66 +0,0 @@ -function displayOverlay() { - overlay.textContent = browser.i18n.getMessage("displayOverlay") - overlay.style.display = 'flex'; - setTimeout(() => { - overlay.style.display = 'none'; - }, 2000); -} -const buttonIds = ['submit', 'share']; -const frame = document.getElementById('frame'); -const codeElement = document.getElementById('code'); -const overlay = document.getElementById('displayOverlay'); - -buttonIds.forEach((buttonId) => { - const buttonElement = document.getElementById(buttonId); - if (buttonElement) { - buttonElement.textContent = browser.i18n.getMessage(buttonId); - buttonElement.addEventListener('click', () => { - const code = codeElement.value; - const locales = navigator.language.slice(0, 2); - let url; - switch (buttonId) { - case 'submit': - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - break; - case 'share': - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - default: - break; - } - if (buttonId === 'submit') { - frame.src = url; - frame.style.display = 'block'; - codeElement.style.display = 'none'; - buttonIds.forEach((id) => { - document.getElementById(id).style.display = 'none'; - }); - } - }); - } -}); -browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then((result) => { - if (result.buttonColorGi) { - document.documentElement.style.setProperty('--button-color', result.buttonColorGi); - } - if (result.buttonTextColorGi) { - document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorGi); - } - if (result.BackgroundGi) { - document.body.style.background = '#4e4b54'; - document.body.style.background = result.BackgroundColorGi; - } - else { - document.body.style.background = 'url("/pictures/backgroundGI.png")'; - document.body.style.backgroundSize = 'cover'; - document.body.style.backgroundRepeat = 'no-repeat'; - document.body.style.backgroundPosition = 'center'; - document.body.style.overflow = 'hidden'; - } -}); - -browser.storage.local.get(['roundingDisable']).then((result) => { - document.documentElement.style.setProperty('--border-radius', result.roundingDisable ? '10px' : '20px'); -}); \ No newline at end of file diff --git a/firefox/onlyHsr.html b/firefox/onlyHsr.html deleted file mode 100644 index 9b8ac8e..0000000 --- a/firefox/onlyHsr.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - -
- -
-
- - -
- -
- - - - \ No newline at end of file diff --git a/firefox/onlyHsr.js b/firefox/onlyHsr.js deleted file mode 100644 index d462d2c..0000000 --- a/firefox/onlyHsr.js +++ /dev/null @@ -1,64 +0,0 @@ -function displayOverlay() { - overlay.textContent = browser.i18n.getMessage("displayOverlay") - overlay.style.display = 'flex'; - setTimeout(() => { - overlay.style.display = 'none'; - }, 2000); -} -const buttonIds = ['submit', 'share']; -const frame = document.getElementById('frame'); -const codeElement = document.getElementById('code'); -const overlay = document.getElementById('displayOverlay'); - -buttonIds.forEach((buttonId) => { - const buttonElement = document.getElementById(buttonId); - if (buttonElement) { - buttonElement.textContent = browser.i18n.getMessage(buttonId); - buttonElement.addEventListener('click', () => { - const code = codeElement.value; - let url; - switch (buttonId) { - case 'submit': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - break; - case 'share': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - default: - break; - } - if (buttonId === 'submit') { - frame.src = url; - frame.style.display = 'block'; - codeElement.style.display = 'none'; - buttonIds.forEach((id) => { - document.getElementById(id).style.display = 'none'; - }); - } - }); - } -}); -browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then((result) => { - if (result.buttonColorHsr) { - document.documentElement.style.setProperty('--button-color', result.buttonColorHsr); - } - if (result.buttonTextColorHsr) { - document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorHsr); - } - if (result.BackgroundHsr) { - document.body.style.background = '#1e274e'; - document.body.style.background = result.BackgroundColorHsr; - } - else { - document.body.style.background = 'url("/pictures/backgroundHSR.png")'; - document.body.style.backgroundSize = 'cover'; - document.body.style.backgroundRepeat = 'no-repeat'; - document.body.style.backgroundPosition = 'center'; - document.body.style.overflow = 'hidden'; - } -}); -browser.storage.local.get(['roundingDisable']).then((result) => { - document.documentElement.style.setProperty('--border-radius', result.roundingDisable ? '10px' : '20px'); -}); \ No newline at end of file diff --git a/firefox/options.js b/firefox/options.js index 51fb00d..261d173 100644 --- a/firefox/options.js +++ b/firefox/options.js @@ -220,4 +220,10 @@ browser.storage.local.get(['iconDisable','roundingDisable', 'snowDisable', 'Back element.value = elements[id]; } } + if (result.buttonColorGi & result.buttonColorHsr) { + } else if (result.buttonColorHsr) {} + else if (result.buttonColorGi) {} + else { + browser.storage.local.set({buttonColorGi: '#a89f96', buttonColorHsr: '#004080'}) + } }); \ No newline at end of file diff --git a/firefox/options_background.js b/firefox/options_background.js deleted file mode 100644 index 9cebe07..0000000 --- a/firefox/options_background.js +++ /dev/null @@ -1,23 +0,0 @@ -async function updatePopup() { - const resultGi = await browser.storage.local.get('onlyGi'); - const resultHsr = await browser.storage.local.get('onlyHsr'); - if (resultGi.onlyGi) { - browser.browserAction.setPopup({ - popup: 'onlyGi.html' - }); - } else if (resultHsr.onlyHsr) { - browser.browserAction.setPopup({ - popup: 'onlyHsr.html' - }); - } else { - browser.browserAction.setPopup({ - popup: 'popup.html' - }); - } -} -browser.storage.onChanged.addListener(async function(changes, areaName) { - if (areaName === 'local' && ('onlyGi' in changes || 'onlyHsr' in changes)) { - await updatePopup(); - } -}); -updatePopup(); \ No newline at end of file diff --git a/firefox/popup.html b/firefox/popup.html index 314d807..8de5836 100644 --- a/firefox/popup.html +++ b/firefox/popup.html @@ -9,10 +9,6 @@ --input-color: rgba(0, 0, 0, 0.5); --input-text-color: white; } - @font-face { - font-family: 'SDK_SC_Web'; - src: url('GIfont.woff2') format('woff2'); - } body { font-family: var(--); padding: 10px; @@ -21,6 +17,8 @@ background-position: center; overflow: hidden; background-image: url(./pictures/background.png); + max-height: 560px; + min-width: 300px; } #input-container { display: flex; @@ -45,10 +43,6 @@ display: flex; justify-content: space-between; } - #submitGI, #submitHSR, #shareGI, #shareHSR { - width: 48%; - margin-top: 10px; - } button { cursor: pointer; display: flex; @@ -63,8 +57,10 @@ z-index: 2; font-family: 'SDK_SC_Web'; box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.5); + width: 48%; + margin-top: 10px; } - #submitGI:hover, #submitHSR:hover, #shareGI:hover, #shareHSR:hover, #options:hover { + button:hover { transform: scale(1.05); border-radius: 10px; display: flex; @@ -90,6 +86,9 @@ z-index: 2; font-family: 'SDK_SC_Web'; } + #hsr-popup, #gi-popup { + display: none; + } @keyframes snowfall { from { transform: translateY(-100vh); @@ -106,16 +105,30 @@
-
- - +
+
+ + +
+
+ + +
-
- - +
+
+ + +
+
+
+
+ + +
-
+ diff --git a/firefox/popup.js b/firefox/popup.js index 3739ae5..c2b3fa3 100644 --- a/firefox/popup.js +++ b/firefox/popup.js @@ -1,49 +1,10 @@ -const buttonIds = ['submitGI', 'shareGI', 'submitHSR', 'shareHSR']; +const buttonIds = ['submitGI', 'shareGI', 'submitHSR', 'shareHSR', 'sthsr', 'sehsr', 'stgi', 'segi']; const frame = document.getElementById('frame'); const codeElement = document.getElementById('code'); const overlay = document.getElementById('displayOverlay'); - -buttonIds.forEach((buttonId) => { - const buttonElement = document.getElementById(buttonId); - if (buttonElement) { - buttonElement.textContent = browser.i18n.getMessage(buttonId); - buttonElement.addEventListener('click', () => { - const code = codeElement.value; - const locales = navigator.language.slice(0, 2); - let url; - switch (buttonId) { - case 'submitGI': - document.body.style.backgroundImage = "url(/pictures/backgroundGI.png)"; - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - break; - case 'submitHSR': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - document.body.style.backgroundImage = "url(/pictures/backgroundHSR.png)"; - break; - case 'shareGI': - url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - case 'shareHSR': - url = `https://hsr.hoyoverse.com/gift?code=${code}`; - navigator.clipboard.writeText(url); - displayOverlay(); - break; - default: - break; - } - if (buttonId === 'submitGI' || buttonId === 'submitHSR') { - frame.src = url; - frame.style.display = 'block'; - codeElement.style.display = 'none'; - buttonIds.forEach((id) => { - document.getElementById(id).style.display = 'none'; - }); - } - }); - } -}); +const font = document.styleSheets[0]; +const HSRfont = "@font-face {font-family: 'SDK_SC_Web'; src: url('HSRfont.woff2') format('woff2');}"; +const GIfont = "@font-face {font-family: 'SDK_SC_Web'; src: url('GIfont.woff2') format('woff2');}"; function displayOverlay() { overlay.textContent = browser.i18n.getMessage("displayOverlay") overlay.style.display = 'flex'; @@ -51,14 +12,171 @@ function displayOverlay() { overlay.style.display = 'none'; }, 2000); } -browser.storage.local.get(['buttonColorMain', 'buttonTextColorMain']).then((result) => { - if (result.buttonColorMain) { - document.documentElement.style.setProperty('--button-color', result.buttonColorMain); - } - if (result.buttonTextColorMain) { - document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorMain); +browser.storage.local.get(['onlyHsr', 'onlyGi']).then(function (result) { + if (result.onlyHsr) { + font.insertRule(HSRfont, font.cssRules.length); + document.getElementById("main-popup").style.display = "none"; + document.getElementById("hsr-popup").style.display = "block"; + buttonIds.forEach((buttonId) => { + const buttonElement = document.getElementById(buttonId); + if (buttonElement) { + buttonElement.textContent = browser.i18n.getMessage(buttonId); + buttonElement.addEventListener('click', () => { + const code = codeElement.value; + let url; + switch (buttonId) { + case 'sthsr': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + break; + case 'sehsr': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + default: + break; + } + if (buttonId === 'sthsr') { + frame.src = url; + frame.style.display = 'block'; + codeElement.style.display = 'none'; + buttonIds.forEach((id) => { + document.getElementById(id).style.display = 'none'; + }); + } + }); + } + }) + browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then((result) => { + if (result.buttonColorHsr) { + document.documentElement.style.setProperty('--button-color', result.buttonColorHsr); + } + if (result.buttonTextColorHsr) { + document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorHsr); + } + if (result.BackgroundHsr) { + document.body.style.background = '#1e274e'; + document.body.style.background = result.BackgroundColorHsr; + } + else { + document.documentElement.style.setProperty('--button-text-color', '#ffffff'); + document.documentElement.style.setProperty('--button-color', '#004080'); + document.body.style.background = 'url("/pictures/backgroundHSR.png")'; + document.body.style.backgroundSize = 'cover'; + document.body.style.backgroundRepeat = 'no-repeat'; + document.body.style.backgroundPosition = 'center'; + document.body.style.overflow = 'hidden'; + } + }); + } else if (result.onlyGi) { + font.insertRule(GIfont, font.cssRules.length); + document.getElementById("main-popup").style.display = "none"; + document.getElementById("gi-popup").style.display = "block"; + buttonIds.forEach((buttonId) => { + const buttonElement = document.getElementById(buttonId); + if (buttonElement) { + buttonElement.textContent = browser.i18n.getMessage(buttonId); + buttonElement.addEventListener('click', () => { + const code = codeElement.value; + const locales = navigator.language.slice(0, 2); + let url; + switch (buttonId) { + case 'stgi': + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + break; + case 'segi': + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + default: + break; + } + if (buttonId === 'stgi') { + frame.src = url; + frame.style.display = 'block'; + codeElement.style.display = 'none'; + buttonIds.forEach((id) => { + document.getElementById(id).style.display = 'none'; + }); + } + }); + } + }); + browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then((result) => { + if (result.buttonColorGi) { + document.documentElement.style.setProperty('--button-color', result.buttonColorGi); + } + if (result.buttonTextColorGi) { + document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorGi); + } + if (result.BackgroundGi) { + document.body.style.background = '#4e4b54'; + document.body.style.background = result.BackgroundColorGi; + } + else { + document.documentElement.style.setProperty('--button-text-color', '#ffffff'); + document.documentElement.style.setProperty('--button-color', '#a89f96'); + document.body.style.background = 'url("/pictures/backgroundGI.png")'; + document.body.style.backgroundSize = 'cover'; + document.body.style.backgroundRepeat = 'no-repeat'; + document.body.style.backgroundPosition = 'center'; + document.body.style.overflow = 'hidden'; + } + }); + } else { + font.insertRule(GIfont, font.cssRules.length); + buttonIds.forEach((buttonId) => { + const buttonElement = document.getElementById(buttonId); + buttonElement.textContent = browser.i18n.getMessage(buttonId); + if (buttonElement) { + buttonElement.addEventListener('click', () => { + const code = codeElement.value; + const locales = navigator.language.slice(0, 2); + let url; + switch (buttonId) { + case 'submitGI': + document.body.style.backgroundImage = "url(/pictures/backgroundGI.png)"; + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + break; + case 'submitHSR': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + document.body.style.backgroundImage = "url(/pictures/backgroundHSR.png)"; + break; + case 'shareGI': + url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + case 'shareHSR': + url = `https://hsr.hoyoverse.com/gift?code=${code}`; + navigator.clipboard.writeText(url); + displayOverlay(); + break; + default: + break; + } + if (buttonId === 'submitGI' || buttonId === 'submitHSR') { + frame.src = url; + frame.style.display = 'block'; + codeElement.style.display = 'none'; + buttonIds.forEach((id) => { + document.getElementById(id).style.display = 'none'; + }); + } + }); + } + }); + browser.storage.local.get(['buttonColorMain', 'buttonTextColorMain']).then((result) => { + if (result.buttonColorMain) { + document.documentElement.style.setProperty('--button-color', result.buttonColorMain); + } + if (result.buttonTextColorMain) { + document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorMain); + } + }); } -}); +}) browser.storage.local.get(['roundingDisable']).then((result) => { document.documentElement.style.setProperty('--border-radius', result.roundingDisable ? '10px' : '20px'); -}); \ No newline at end of file +});