+
+
+
+
+
+
+
From f8f9a1b522cd94f627dfd523506582a8a09db8ca Mon Sep 17 00:00:00 2001
From: Kajitsy
-
-
-
-
-
-
-
-
-
\ 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 @@ - - -
- - - -
-