diff --git a/chromium/_locales/en/messages.json b/chromium/_locales/en/messages.json
index b69aa70..860d6c8 100644
--- a/chromium/_locales/en/messages.json
+++ b/chromium/_locales/en/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.3"
+ "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.4"
},
"submit": {
"message": "Submit"
@@ -62,6 +62,9 @@
"labelRounding": {
"message": "Disable roundings"
},
+ "labelIcon": {
+ "message": "Disable icon change"
+ },
"labelSnow": {
"message": "Turn off the snowfall"
}
diff --git a/chromium/_locales/es/messages.json b/chromium/_locales/es/messages.json
index ec6691a..bfed1ee 100644
--- a/chromium/_locales/es/messages.json
+++ b/chromium/_locales/es/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.3"
+ "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.4"
},
"submit": {
"message": "Enviar"
@@ -62,6 +62,9 @@
"labelRounding": {
"message": "Desactivar el redondeo"
},
+ "labelIcon": {
+ "message": "Desactivar el cambio de icono"
+ },
"labelSnow": {
"message": "Apagar la nevada"
}
diff --git a/chromium/_locales/jp/messages.json b/chromium/_locales/jp/messages.json
index 47e0604..fefedb5 100644
--- a/chromium/_locales/jp/messages.json
+++ b/chromium/_locales/jp/messages.json
@@ -59,6 +59,9 @@
"labelRounding": {
"message": "丸めを無効にする"
},
+ "labelIcon": {
+ "message": "アイコンの変更を無効にする"
+ },
"labelSnow": {
"message": "降雪のスイッチを切る"
}
diff --git a/chromium/_locales/ru/messages.json b/chromium/_locales/ru/messages.json
index 370566d..7a4538d 100644
--- a/chromium/_locales/ru/messages.json
+++ b/chromium/_locales/ru/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.3"
+ "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.4"
},
"submit": {
"message": "Ввести"
@@ -62,6 +62,9 @@
"labelRounding": {
"message": "Отключить закругления"
},
+ "labelIcon": {
+ "message": "Отключить смену иконок"
+ },
"labelSnow": {
"message": "Отключить снегопад"
}
diff --git a/chromium/dailychecker.js b/chromium/dailychecker.js
index 4e87950..0b5dfe4 100644
--- a/chromium/dailychecker.js
+++ b/chromium/dailychecker.js
@@ -1,5 +1,6 @@
if (typeof browser === "undefined") {
browser = chrome;
+ browser.browserAction = chrome.action;
}
function getCurrDay() {
var now = new Date();
@@ -7,6 +8,8 @@ function getCurrDay() {
now.setHours(now.getHours() + 8);
return Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
}
+var HSRwork;
+var GIwork;
function GIrequest() {
var currDay = getCurrDay();
fetch("https://sg-hk4e-api.hoyolab.com/event/sol/sign?act_id=e202102251931481", {
@@ -21,12 +24,17 @@ function GIrequest() {
if (data.retcode == 0 || data.retcode == -5003) {
console.log("GIsuccess", data);
browser.storage.local.set({dc_lastCheked: currDay});
- } else if (data.retcode == -10002) {
- console.log("GIbadrequest", data);
- } else {
+ GIwork = true;
+ } else {
console.log("GIwarning", data);
+ browser.storage.local.set({dc_lastCheked: currDay});
+ GIwork = false;
}
})
+ .catch(error => {
+ console.log("GIbadrequest", error);
+ GIwork = false;
+ });
}
function HSRrequest() {
var currDay = getCurrDay();
@@ -42,12 +50,34 @@ function HSRrequest() {
if (data.retcode == 0 || data.retcode == -5003) {
console.log("HSRsuccess", data);
browser.storage.local.set({dc_lastCheked: currDay});
- } else if (data.retcode == -10002) {
- console.log("HSRbadrequest", data);
+ HSRwork = true;
} else {
console.log("HSRwarning", data);
+ browser.storage.local.set({dc_lastCheked: currDay});
+ HSRwork = false;
}
})
+ .catch(error => {
+ console.log("HSRbadrequest", error);
+ HSRwork = false;
+ });
+}
+function icon(){
+ browser.storage.local.get(['iconDisable']).then(function (result) {
+ if (result.iconDisable) {
+ browser.browserAction.setIcon({path: "/pictures/icon.png"});
+ } else {
+ if (GIwork == true && HSRwork == true) {
+ browser.browserAction.setIcon({path: "/pictures/icon.png"});
+ } else if (GIwork == true && HSRwork == false) {
+ browser.browserAction.setIcon({path: "/pictures/icon_warn.png"});
+ } else if (GIwork == false && HSRwork == true) {
+ browser.browserAction.setIcon({path: "/pictures/icon_warn.png"});
+ } else {
+ browser.browserAction.setIcon({path: "/pictures/icon_error.png"});
+ }
+ }
+ })
}
function check() {
browser.storage.local.get({dc_lastCheked: null}).then(storage => {
@@ -55,6 +85,7 @@ function check() {
if (storage.dc_lastCheked != currDay) {
HSRrequest();
GIrequest();
+ setTimeout(icon, 5000);
}
});
}
diff --git a/chromium/manifest.json b/chromium/manifest.json
index b036293..6a5551f 100644
--- a/chromium/manifest.json
+++ b/chromium/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Genshin/Star Rail CodeEntter",
- "version": "2.2.3",
+ "version": "2.2.3.1",
"description": "__MSG_extensionDescription__",
"default_locale": "en",
"icons": {
diff --git a/chromium/onlyGi.html b/chromium/onlyGi.html
index 054cb82..c1f2604 100644
--- a/chromium/onlyGi.html
+++ b/chromium/onlyGi.html
@@ -20,7 +20,6 @@
background-repeat: no-repeat;
background-position: center;
overflow: hidden;
- width: 170vh;
}
#input-container {
display: flex;
@@ -64,14 +63,13 @@
font-family: 'SDK_SC_Web';
box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.5);
}
- #submit:hover, #share:hover, #options:hover {
+ #submit:hover, #share:hover {
transform: scale(1.05);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--border-radius);
- box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.5);
}
#frame {
border: none;
diff --git a/chromium/onlyGi.js b/chromium/onlyGi.js
index 6ab0891..2b422b8 100644
--- a/chromium/onlyGi.js
+++ b/chromium/onlyGi.js
@@ -1,76 +1,50 @@
if (typeof browser === "undefined") {
browser = chrome;
}
-['submit', 'share'].forEach(function (buttonId) {
+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', function () {
- const code = document.getElementById('code').value;
+ 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}`;
- document.getElementById('frame').src = url;
break;
-
case 'share':
url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`;
navigator.clipboard.writeText(url);
displayOverlay();
break;
-
default:
break;
}
if (buttonId === 'submit') {
- const frame = document.getElementById('frame');
+ frame.src = url;
frame.style.display = 'block';
- document.getElementById('code').style.display = 'none';
- document.getElementById('submit').style.display = 'none';
- document.getElementById('share').style.display = 'none';
+ codeElement.style.display = 'none';
+ buttonIds.forEach((id) => {
+ document.getElementById(id).style.display = 'none';
+ });
}
});
}
});
-
-function displayOverlay() {
- const overlay = document.getElementById('displayOverlay');
- overlay.textContent = browser.i18n.getMessage("displayOverlay")
- overlay.style.display = 'flex';
- document.body.appendChild(overlay);
- setTimeout(function () {
- overlay.style.display = 'none';
- }, 2000);
-}
-function createSnowflake() {
- const snowflake = document.createElement('div');
- snowflake.className = 'snowflake';
- snowflake.innerHTML = '❄';
- const size = Math.random() * 3 + 2;
- const fontSize = size > 5 ? 5 : size;
- snowflake.style.fontSize = fontSize + 'rem';
- snowflake.style.position = 'absolute';
- snowflake.style.color = 'white';
- snowflake.style.pointerEvents = 'none';
- const startPositionLeft = Math.random() * window.innerWidth;
- const duration = Math.random() * 4 + 3 + 's';
- const delay = Math.random() * 10 + 's';
- snowflake.style.left = startPositionLeft + 'px';
- snowflake.style.animation = `snowfall ${duration} linear ${delay} infinite`;
- document.body.appendChild(snowflake);
- snowflake.addEventListener('animationiteration', () => {
- snowflake.style.left = Math.random() * window.innerWidth + 'px';
- });
-}
-function generateSnowfall() {
- for (let i = 0; i < 20; i++) {
- createSnowflake();
- }
-}
-browser.storage.local.get(['snowDisable', 'buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then(function (result) {
+browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then((result) => {
if (result.buttonColorGi) {
document.documentElement.style.setProperty('--button-color', result.buttonColorGi);
}
@@ -88,19 +62,8 @@ browser.storage.local.get(['snowDisable', 'buttonColorGi', 'buttonTextColorGi',
document.body.style.backgroundPosition = 'center';
document.body.style.overflow = 'hidden';
}
- if (result.snowDisable){
- console.log("Snow Disable");
- }
- else {
- console.log("Snow Enable");
- generateSnowfall();
- }
});
-browser.storage.local.get(['roundingDisable']).then(function (result) {
- if (result.roundingDisable) {
- document.documentElement.style.setProperty('--border-radius', '10px')
- }
- else {
- document.documentElement.style.setProperty('--border-radius', '20px')
- }
+
+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
index 79624ef..9b8ac8e 100644
--- a/chromium/onlyHsr.html
+++ b/chromium/onlyHsr.html
@@ -20,7 +20,6 @@
background-repeat: no-repeat;
background-position: center;
overflow: hidden;
- width: 170vh;
}
#input-container {
display: flex;
@@ -72,7 +71,6 @@
align-items: center;
justify-content: center;
border-radius: var(--border-radius);
- box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.5);
}
#frame {
border: none;
diff --git a/chromium/onlyHsr.js b/chromium/onlyHsr.js
index 5122e57..3aa96c0 100644
--- a/chromium/onlyHsr.js
+++ b/chromium/onlyHsr.js
@@ -1,51 +1,49 @@
if (typeof browser === "undefined") {
browser = chrome;
}
-['submit', 'share'].forEach(function (buttonId) {
+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', function () {
- const code = document.getElementById('code').value;
+ buttonElement.addEventListener('click', () => {
+ const code = codeElement.value;
let url;
switch (buttonId) {
case 'submit':
url = `https://hsr.hoyoverse.com/gift?code=${code}`;
- document.getElementById('frame').src = url;
break;
-
case 'share':
url = `https://hsr.hoyoverse.com/gift?code=${code}`;
navigator.clipboard.writeText(url);
displayOverlay();
break;
-
default:
break;
}
-
if (buttonId === 'submit') {
- const frame = document.getElementById('frame');
+ frame.src = url;
frame.style.display = 'block';
- document.getElementById('code').style.display = 'none';
- document.getElementById('submit').style.display = 'none';
- document.getElementById('share').style.display = 'none';
+ codeElement.style.display = 'none';
+ buttonIds.forEach((id) => {
+ document.getElementById(id).style.display = 'none';
+ });
}
});
}
});
-
-function displayOverlay() {
- const overlay = document.getElementById('displayOverlay');
- overlay.textContent = browser.i18n.getMessage("displayOverlay")
- overlay.style.display = 'flex';
- document.body.appendChild(overlay);
- setTimeout(function () {
- overlay.style.display = 'none';
- }, 2000);
-}
-browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then(function (result) {
+browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then((result) => {
if (result.buttonColorHsr) {
document.documentElement.style.setProperty('--button-color', result.buttonColorHsr);
}
@@ -64,11 +62,6 @@ browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHs
document.body.style.overflow = 'hidden';
}
});
-browser.storage.local.get(['roundingDisable']).then(function (result) {
- if (result.roundingDisable) {
- document.documentElement.style.setProperty('--border-radius', '10px')
- }
- else {
- document.documentElement.style.setProperty('--border-radius', '20px')
- }
+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.html b/chromium/options.html
index 0abea32..6b1511b 100644
--- a/chromium/options.html
+++ b/chromium/options.html
@@ -102,6 +102,10 @@
+
+
+
+
diff --git a/chromium/options.js b/chromium/options.js
index 3042eea..5785107 100644
--- a/chromium/options.js
+++ b/chromium/options.js
@@ -1,27 +1,33 @@
if (typeof browser === "undefined") {
browser = chrome;
}
-document.getElementById('labelGi').textContent = browser.i18n.getMessage("labelGi");
-document.getElementById('labelHsr').textContent = browser.i18n.getMessage("labelHsr");
-document.getElementById('labelSnow').textContent = browser.i18n.getMessage("labelSnow");
-document.getElementById('labelRounding').textContent = browser.i18n.getMessage("labelRounding");
-document.getElementById('labelBackgroundGi').textContent = browser.i18n.getMessage("labelBackground");
-document.getElementById('labelBackgroundColorGi').textContent = browser.i18n.getMessage("labelBackgroundColor");
-document.getElementById('labelBackgroundHsr').textContent = browser.i18n.getMessage("labelBackground");
-document.getElementById('labelBackgroundColorHsr').textContent = browser.i18n.getMessage("labelBackgroundColor");
-document.getElementById('resetpopup').textContent = browser.i18n.getMessage("reset");
-document.getElementById('resetGi').textContent = browser.i18n.getMessage("reset");
-document.getElementById('resetHsr').textContent = browser.i18n.getMessage("reset");
-document.getElementById('labelButtonColor').textContent = browser.i18n.getMessage("labelButtonColor");
-document.getElementById('labelButtonColorGi').textContent = browser.i18n.getMessage("labelButtonColor");
-document.getElementById('labelButtonColorHsr').textContent = browser.i18n.getMessage("labelButtonColor");
-document.getElementById('labelTextColor').textContent = browser.i18n.getMessage("labelTextColor");
-document.getElementById('labelTextColorGi').textContent = browser.i18n.getMessage("labelTextColor");
-document.getElementById('labelTextColorHsr').textContent = browser.i18n.getMessage("labelTextColor");
-document.getElementById('labelGlobal-settings').textContent = browser.i18n.getMessage("labelGlobal");
-document.getElementById('labelMainPopup-settings').textContent = browser.i18n.getMessage("labelMainPopup");
-document.getElementById('labelOnlyGi-settings').textContent = browser.i18n.getMessage("labelOnlyGi");
-document.getElementById('labelOnlyHsr-settings').textContent = browser.i18n.getMessage("labelOnlyHsr");
+const labels = {
+ 'labelGi': 'labelGi',
+ 'labelHsr': 'labelHsr',
+ 'labelSnow': 'labelSnow',
+ 'labelIcon': 'labelIcon',
+ 'labelRounding': 'labelRounding',
+ 'labelBackgroundGi': 'labelBackground',
+ 'labelBackgroundColorGi': 'labelBackgroundColor',
+ 'labelBackgroundHsr': 'labelBackground',
+ 'labelBackgroundColorHsr': 'labelBackgroundColor',
+ 'resetpopup': 'reset',
+ 'resetGi': 'reset',
+ 'resetHsr': 'reset',
+ 'labelButtonColor': 'labelButtonColor',
+ 'labelButtonColorGi': 'labelButtonColor',
+ 'labelButtonColorHsr': 'labelButtonColor',
+ 'labelTextColor': 'labelTextColor',
+ 'labelTextColorGi': 'labelTextColor',
+ 'labelTextColorHsr': 'labelTextColor',
+ 'labelGlobal-settings': 'labelGlobal',
+ 'labelMainPopup-settings': 'labelMainPopup',
+ 'labelOnlyGi-settings': 'labelOnlyGi',
+ 'labelOnlyHsr-settings': 'labelOnlyHsr'
+};
+for (let id in labels) {
+ document.getElementById(id).textContent = browser.i18n.getMessage(labels[id]);
+}
function showSettingsSection(section) {
var sections = ['global-settings','main-popup-settings', 'onlyGi-settings', 'onlyHsr-settings'];
sections.forEach(function (s) {
@@ -83,24 +89,18 @@ document.getElementById('BackgroundColorHsr').addEventListener('input', function
BackgroundColorHsr: BackgroundColorHsr
});
});
-document.getElementById('onlyHsr').addEventListener('change', function() {
- var onlyHsr = document.getElementById('onlyHsr').checked;
- browser.storage.local.set({
- onlyHsr: onlyHsr
- });
-});
-document.getElementById('onlyGi').addEventListener('change', function() {
- var onlyGi = document.getElementById('onlyGi').checked;
- browser.storage.local.set({
- onlyGi: onlyGi
- });
-});
document.getElementById('snowDisable').addEventListener('change', function() {
var snowDisable = document.getElementById('snowDisable').checked;
browser.storage.local.set({
snowDisable: snowDisable
});
});
+document.getElementById('iconDisable').addEventListener('change', function() {
+ var iconDisable = document.getElementById('iconDisable').checked;
+ browser.storage.local.set({
+ iconDisable: iconDisable
+ });
+});
document.getElementById('roundingDisable').addEventListener('change', function() {
var roundingDisable = document.getElementById('roundingDisable').checked;
browser.storage.local.set({
@@ -145,36 +145,6 @@ document.getElementById('resetHsr').addEventListener('click', function() {
buttonTextColorHsr: '#ffffff',
BackgroundColorHsr: '#1e274e'
})});
-browser.storage.local.get(['roundingDisable', 'snowDisable', 'BackgroundHsr', 'BackgroundColorHsr', 'BackgroundGi', 'BackgroundColorGi', 'buttonColorMain', 'buttonColorGi', 'buttonColorHsr', 'buttonTextColorMain', 'buttonTextColorGi', 'buttonTextColorHsr', 'onlyHsr', 'onlyGi'], function(result) {
- var buttonColorMain = result.buttonColorMain ? result.buttonColorMain : '#9a609a';
- var buttonColorGi = result.buttonColorGi ? result.buttonColorGi : '#a89f96';
- var buttonColorHsr = result.buttonColorHsr ? result.buttonColorHsr : '#004080';
- var buttonTextColorMain = result.buttonTextColorMain ? result.buttonTextColorMain : '#ffffff';
- var buttonTextColorGi = result.buttonTextColorGi ? result.buttonTextColorGi : '#ffffff';
- var buttonTextColorHsr = result.buttonTextColorHsr ? result.buttonTextColorHsr : '#ffffff';
- var BackgroundColorGi = result.BackgroundColorGi ? result.BackgroundColorGi: '#4e4b54';
- var BackgroundColorHsr = result.BackgroundColorHsr ? result.BackgroundColorHsr: '#1e274e';
- var onlyHsr = result.onlyHsr ? result.onlyHsr : false;
- var onlyGi = result.onlyGi ? result.onlyGi : false;
- var snowDisable = result.snowDisable ? result.snowDisable: false;
- var roundingDisable = result.roundingDisable ? result.roundingDisable: false;
- var BackgroundGi = result.BackgroundGi ? result.BackgroundGi: false;
- var BackgroundHsr = result.BackgroundHsr ? result.BackgroundHsr: false;
- document.getElementById('buttonColorMain').value = buttonColorMain;
- document.getElementById('buttonColorGi').value = buttonColorGi;
- document.getElementById('buttonColorHsr').value = buttonColorHsr;
- document.getElementById('buttonTextColorMain').value = buttonTextColorMain;
- document.getElementById('buttonTextColorGi').value = buttonTextColorGi;
- document.getElementById('buttonTextColorHsr').value = buttonTextColorHsr;
- document.getElementById('BackgroundColorGi').value = BackgroundColorGi;
- document.getElementById('BackgroundColorHsr').value = BackgroundColorHsr;
- document.getElementById('onlyHsr').checked = onlyHsr;
- document.getElementById('onlyGi').checked = onlyGi;
- document.getElementById('snowDisable').checked = snowDisable;
- document.getElementById('roundingDisable').checked = roundingDisable;
- document.getElementById('BackgroundHsr').checked = BackgroundHsr;
- document.getElementById('BackgroundGi').checked = BackgroundGi;
-});
browser.storage.local.get(['roundingDisable']).then(function (result) {
if (result.roundingDisable) {
document.documentElement.style.setProperty('--border-radius', '10px')
@@ -182,4 +152,75 @@ browser.storage.local.get(['roundingDisable']).then(function (result) {
else {
document.documentElement.style.setProperty('--border-radius', '20px')
}
+});
+browser.storage.local.get(['iconDisable','roundingDisable', 'snowDisable', 'BackgroundHsr', 'BackgroundColorHsr', 'BackgroundGi', 'BackgroundColorGi', 'buttonColorMain', 'buttonColorGi', 'buttonColorHsr', 'buttonTextColorMain', 'buttonTextColorGi', 'buttonTextColorHsr', 'onlyHsr', 'onlyGi'], function(result) {
+ const defaults = {
+ 'buttonColorMain': '#9a609a',
+ 'buttonColorGi': '#a89f96',
+ 'buttonColorHsr': '#004080',
+ 'buttonTextColorMain': '#ffffff',
+ 'buttonTextColorGi': '#ffffff',
+ 'buttonTextColorHsr': '#ffffff',
+ 'BackgroundColorGi': '#4e4b54',
+ 'BackgroundColorHsr': '#1e274e',
+ 'onlyHsr': false,
+ 'onlyGi': false,
+ 'iconDisable': false,
+ 'snowDisable': false,
+ 'roundingDisable': false,
+ 'BackgroundGi': false,
+ 'BackgroundHsr': false
+ };
+ for (let key in defaults) {
+ window[key] = result[key] ? result[key] : defaults[key];
+ }
+ document.getElementById('onlyHsr').addEventListener('change', function() {
+ var onlyHsr = document.getElementById('onlyHsr').checked;
+ if (onlyHsr) {
+ document.getElementById('onlyGi').checked = false;
+ browser.storage.local.set({
+ onlyGi: false
+ });
+ }
+ browser.storage.local.set({
+ onlyHsr: onlyHsr
+ });
+ });
+ document.getElementById('onlyGi').addEventListener('change', function() {
+ var onlyGi = document.getElementById('onlyGi').checked;
+ if (onlyGi) {
+ document.getElementById('onlyHsr').checked = false;
+ browser.storage.local.set({
+ onlyHsr: false
+ });
+ }
+ browser.storage.local.set({
+ onlyGi: onlyGi
+ });
+ });
+ const elements = {
+ 'buttonColorMain': buttonColorMain,
+ 'buttonColorGi': buttonColorGi,
+ 'buttonColorHsr': buttonColorHsr,
+ 'buttonTextColorMain': buttonTextColorMain,
+ 'buttonTextColorGi': buttonTextColorGi,
+ 'buttonTextColorHsr': buttonTextColorHsr,
+ 'BackgroundColorGi': BackgroundColorGi,
+ 'BackgroundColorHsr': BackgroundColorHsr,
+ 'onlyHsr': onlyHsr,
+ 'onlyGi': onlyGi,
+ 'snowDisable': snowDisable,
+ 'iconDisable': iconDisable,
+ 'roundingDisable': roundingDisable,
+ 'BackgroundHsr': BackgroundHsr,
+ 'BackgroundGi': BackgroundGi
+ };
+ for (let id in elements) {
+ let element = document.getElementById(id);
+ if (element.type === "checkbox") {
+ element.checked = elements[id];
+ } else {
+ element.value = elements[id];
+ }
+ }
});
\ No newline at end of file
diff --git a/chromium/pictures/icon_error.png b/chromium/pictures/icon_error.png
new file mode 100644
index 0000000..2f1dea1
Binary files /dev/null and b/chromium/pictures/icon_error.png differ
diff --git a/chromium/pictures/icon_warn.png b/chromium/pictures/icon_warn.png
new file mode 100644
index 0000000..eda23b8
Binary files /dev/null and b/chromium/pictures/icon_warn.png differ
diff --git a/chromium/popup.html b/chromium/popup.html
index 38c5e1c..314d807 100644
--- a/chromium/popup.html
+++ b/chromium/popup.html
@@ -21,7 +21,6 @@
background-position: center;
overflow: hidden;
background-image: url(./pictures/background.png);
- width: 170vh;
}
#input-container {
display: flex;
@@ -72,7 +71,6 @@
align-items: center;
justify-content: center;
border-radius: var(--border-radius);
- box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.5);
}
#frame {
border: none;
diff --git a/chromium/popup.js b/chromium/popup.js
index d7ef180..2dfa3c9 100644
--- a/chromium/popup.js
+++ b/chromium/popup.js
@@ -1,63 +1,60 @@
if (typeof browser === "undefined") {
browser = chrome;
}
-['submitGI', 'shareGI', 'submitHSR', 'shareHSR'].forEach(function (buttonId) {
+const buttonIds = ['submitGI', 'shareGI', 'submitHSR', 'shareHSR'];
+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', function () {
- const code = document.getElementById('code').value;
- let url;
+ 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}`;
- document.getElementById('frame').src = url;
break;
case 'submitHSR':
url = `https://hsr.hoyoverse.com/gift?code=${code}`;
document.body.style.backgroundImage = "url(/pictures/backgroundHSR.png)";
- document.getElementById('frame').src = url;
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') {
- const frame = document.getElementById('frame');
+ frame.src = url;
frame.style.display = 'block';
- document.getElementById('code').style.display = 'none';
- document.getElementById('submitGI').style.display = 'none';
- document.getElementById('shareGI').style.display = 'none';
- document.getElementById('submitHSR').style.display = 'none';
- document.getElementById('shareHSR').style.display = 'none';
+ codeElement.style.display = 'none';
+ buttonIds.forEach((id) => {
+ document.getElementById(id).style.display = 'none';
+ });
}
});
}
});
function displayOverlay() {
- const overlay = document.getElementById('displayOverlay');
overlay.textContent = browser.i18n.getMessage("displayOverlay")
overlay.style.display = 'flex';
- document.body.appendChild(overlay);
- setTimeout(function () {
+ setTimeout(() => {
overlay.style.display = 'none';
}, 2000);
}
-browser.storage.local.get(['buttonColorMain', 'buttonTextColorMain']).then(function (result) {
+browser.storage.local.get(['buttonColorMain', 'buttonTextColorMain']).then((result) => {
if (result.buttonColorMain) {
document.documentElement.style.setProperty('--button-color', result.buttonColorMain);
}
@@ -65,11 +62,6 @@ browser.storage.local.get(['buttonColorMain', 'buttonTextColorMain']).then(funct
document.documentElement.style.setProperty('--button-text-color', result.buttonTextColorMain);
}
});
-browser.storage.local.get(['roundingDisable']).then(function (result) {
- if (result.roundingDisable) {
- document.documentElement.style.setProperty('--border-radius', '10px')
- }
- else {
- document.documentElement.style.setProperty('--border-radius', '20px')
- }
+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/_locales/en/messages.json b/firefox/_locales/en/messages.json
index b69aa70..860d6c8 100644
--- a/firefox/_locales/en/messages.json
+++ b/firefox/_locales/en/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.3"
+ "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.4"
},
"submit": {
"message": "Submit"
@@ -62,6 +62,9 @@
"labelRounding": {
"message": "Disable roundings"
},
+ "labelIcon": {
+ "message": "Disable icon change"
+ },
"labelSnow": {
"message": "Turn off the snowfall"
}
diff --git a/firefox/_locales/es/messages.json b/firefox/_locales/es/messages.json
index ec6691a..bfed1ee 100644
--- a/firefox/_locales/es/messages.json
+++ b/firefox/_locales/es/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.3"
+ "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.4"
},
"submit": {
"message": "Enviar"
@@ -62,6 +62,9 @@
"labelRounding": {
"message": "Desactivar el redondeo"
},
+ "labelIcon": {
+ "message": "Desactivar el cambio de icono"
+ },
"labelSnow": {
"message": "Apagar la nevada"
}
diff --git a/firefox/_locales/jp/messages.json b/firefox/_locales/jp/messages.json
index 47e0604..fefedb5 100644
--- a/firefox/_locales/jp/messages.json
+++ b/firefox/_locales/jp/messages.json
@@ -59,6 +59,9 @@
"labelRounding": {
"message": "丸めを無効にする"
},
+ "labelIcon": {
+ "message": "アイコンの変更を無効にする"
+ },
"labelSnow": {
"message": "降雪のスイッチを切る"
}
diff --git a/firefox/_locales/ru/messages.json b/firefox/_locales/ru/messages.json
index 370566d..7a4538d 100644
--- a/firefox/_locales/ru/messages.json
+++ b/firefox/_locales/ru/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.3"
+ "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.4"
},
"submit": {
"message": "Ввести"
@@ -62,6 +62,9 @@
"labelRounding": {
"message": "Отключить закругления"
},
+ "labelIcon": {
+ "message": "Отключить смену иконок"
+ },
"labelSnow": {
"message": "Отключить снегопад"
}
diff --git a/firefox/dailychecker.js b/firefox/dailychecker.js
index 7bc0b15..f4c476d 100644
--- a/firefox/dailychecker.js
+++ b/firefox/dailychecker.js
@@ -4,6 +4,8 @@ function getCurrDay() {
now.setHours(now.getHours() + 8);
return Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
}
+var HSRwork;
+var GIwork;
function GIrequest() {
var currDay = getCurrDay();
fetch("https://sg-hk4e-api.hoyolab.com/event/sol/sign?act_id=e202102251931481", {
@@ -18,12 +20,17 @@ function GIrequest() {
if (data.retcode == 0 || data.retcode == -5003) {
console.log("GIsuccess", data);
browser.storage.local.set({dc_lastCheked: currDay});
- } else if (data.retcode == -10002) {
- console.log("GIbadrequest", data);
- } else {
+ GIwork = true;
+ } else {
console.log("GIwarning", data);
+ browser.storage.local.set({dc_lastCheked: currDay});
+ GIwork = false;
}
})
+ .catch(error => {
+ console.log("GIbadrequest", error);
+ GIwork = false;
+ });
}
function HSRrequest() {
var currDay = getCurrDay();
@@ -39,12 +46,34 @@ function HSRrequest() {
if (data.retcode == 0 || data.retcode == -5003) {
console.log("HSRsuccess", data);
browser.storage.local.set({dc_lastCheked: currDay});
- } else if (data.retcode == -10002) {
- console.log("HSRbadrequest", data);
+ HSRwork = true;
} else {
console.log("HSRwarning", data);
+ browser.storage.local.set({dc_lastCheked: currDay});
+ HSRwork = false;
}
})
+ .catch(error => {
+ console.log("HSRbadrequest", error);
+ HSRwork = false;
+ });
+}
+function icon(){
+ browser.storage.local.get(['iconDisable']).then(function (result) {
+ if (result.iconDisable) {
+ browser.browserAction.setIcon({path: "/pictures/icon.png"});
+ } else {
+ if (GIwork == true && HSRwork == true) {
+ browser.browserAction.setIcon({path: "/pictures/icon.png"});
+ } else if (GIwork == true && HSRwork == false) {
+ browser.browserAction.setIcon({path: "/pictures/icon_warn.png"});
+ } else if (GIwork == false && HSRwork == true) {
+ browser.browserAction.setIcon({path: "/pictures/icon_warn.png"});
+ } else {
+ browser.browserAction.setIcon({path: "/pictures/icon_error.png"});
+ }
+ }
+ })
}
function check() {
browser.storage.local.get({dc_lastCheked: null}).then(storage => {
@@ -52,6 +81,7 @@ function check() {
if (storage.dc_lastCheked != currDay) {
HSRrequest();
GIrequest();
+ setTimeout(icon, 5000);
}
});
}
diff --git a/firefox/manifest.json b/firefox/manifest.json
index 338d0a2..aa6718e 100644
--- a/firefox/manifest.json
+++ b/firefox/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Genshin/Star Rail CodeEntter",
- "version": "2.2.3",
+ "version": "2.2.3.1",
"description": "__MSG_extensionDescription__",
"default_locale": "en",
"icons": {
diff --git a/firefox/onlyGi.html b/firefox/onlyGi.html
index 32dc951..c1f2604 100644
--- a/firefox/onlyGi.html
+++ b/firefox/onlyGi.html
@@ -63,14 +63,13 @@
font-family: 'SDK_SC_Web';
box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.5);
}
- #submit:hover, #share:hover, #options:hover {
+ #submit:hover, #share:hover {
transform: scale(1.05);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--border-radius);
- box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.5);
}
#frame {
border: none;
diff --git a/firefox/onlyGi.js b/firefox/onlyGi.js
index d6ff204..572e885 100644
--- a/firefox/onlyGi.js
+++ b/firefox/onlyGi.js
@@ -1,48 +1,47 @@
-['submit', 'share'].forEach(function (buttonId) {
+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', function () {
- const code = document.getElementById('code').value;
+ 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}`;
- document.getElementById('frame').src = url;
break;
-
case 'share':
url = `https://genshin.hoyoverse.com/${locales}/gift?code=${code}`;
navigator.clipboard.writeText(url);
displayOverlay();
break;
-
default:
break;
}
if (buttonId === 'submit') {
- const frame = document.getElementById('frame');
+ frame.src = url;
frame.style.display = 'block';
- document.getElementById('code').style.display = 'none';
- document.getElementById('submit').style.display = 'none';
- document.getElementById('share').style.display = 'none';
+ codeElement.style.display = 'none';
+ buttonIds.forEach((id) => {
+ document.getElementById(id).style.display = 'none';
+ });
}
});
}
});
-
-function displayOverlay() {
- const overlay = document.getElementById('displayOverlay');
- overlay.textContent = browser.i18n.getMessage("displayOverlay")
- overlay.style.display = 'flex';
- document.body.appendChild(overlay);
- setTimeout(function () {
- overlay.style.display = 'none';
- }, 2000);
-}
-browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then(function (result) {
+browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi', 'BackgroundColorGi']).then((result) => {
if (result.buttonColorGi) {
document.documentElement.style.setProperty('--button-color', result.buttonColorGi);
}
@@ -61,11 +60,7 @@ browser.storage.local.get(['buttonColorGi', 'buttonTextColorGi', 'BackgroundGi',
document.body.style.overflow = 'hidden';
}
});
-browser.storage.local.get(['roundingDisable']).then(function (result) {
- if (result.roundingDisable) {
- document.documentElement.style.setProperty('--border-radius', '10px')
- }
- else {
- document.documentElement.style.setProperty('--border-radius', '20px')
- }
+
+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
index 6f319fc..9b8ac8e 100644
--- a/firefox/onlyHsr.html
+++ b/firefox/onlyHsr.html
@@ -71,7 +71,6 @@
align-items: center;
justify-content: center;
border-radius: var(--border-radius);
- box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.5);
}
#frame {
border: none;
diff --git a/firefox/onlyHsr.js b/firefox/onlyHsr.js
index ad25809..d462d2c 100644
--- a/firefox/onlyHsr.js
+++ b/firefox/onlyHsr.js
@@ -1,48 +1,46 @@
-['submit', 'share'].forEach(function (buttonId) {
+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', function () {
- const code = document.getElementById('code').value;
+ buttonElement.addEventListener('click', () => {
+ const code = codeElement.value;
let url;
switch (buttonId) {
case 'submit':
url = `https://hsr.hoyoverse.com/gift?code=${code}`;
- document.getElementById('frame').src = url;
break;
-
case 'share':
url = `https://hsr.hoyoverse.com/gift?code=${code}`;
navigator.clipboard.writeText(url);
displayOverlay();
break;
-
default:
break;
}
-
if (buttonId === 'submit') {
- const frame = document.getElementById('frame');
+ frame.src = url;
frame.style.display = 'block';
- document.getElementById('code').style.display = 'none';
- document.getElementById('submit').style.display = 'none';
- document.getElementById('share').style.display = 'none';
+ codeElement.style.display = 'none';
+ buttonIds.forEach((id) => {
+ document.getElementById(id).style.display = 'none';
+ });
}
});
}
});
-
-function displayOverlay() {
- const overlay = document.getElementById('displayOverlay');
- overlay.textContent = browser.i18n.getMessage("displayOverlay")
- overlay.style.display = 'flex';
- document.body.appendChild(overlay);
- setTimeout(function () {
- overlay.style.display = 'none';
- }, 2000);
-}
-browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then(function (result) {
+browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHsr', 'BackgroundColorHsr']).then((result) => {
if (result.buttonColorHsr) {
document.documentElement.style.setProperty('--button-color', result.buttonColorHsr);
}
@@ -61,11 +59,6 @@ browser.storage.local.get(['buttonColorHsr', 'buttonTextColorHsr', 'BackgroundHs
document.body.style.overflow = 'hidden';
}
});
-browser.storage.local.get(['roundingDisable']).then(function (result) {
- if (result.roundingDisable) {
- document.documentElement.style.setProperty('--border-radius', '10px')
- }
- else {
- document.documentElement.style.setProperty('--border-radius', '20px')
- }
+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.html b/firefox/options.html
index a0a6cbf..7ddbf86 100644
--- a/firefox/options.html
+++ b/firefox/options.html
@@ -102,6 +102,10 @@
+
+
+
+
@@ -156,6 +160,7 @@
-
+
+