diff --git a/chromium/_locales/en/messages.json b/chromium/_locales/en/messages.json index 6325025..52b5f54 100644 --- a/chromium/_locales/en/messages.json +++ b/chromium/_locales/en/messages.json @@ -1,6 +1,6 @@ { "extensionDescription": { - "message": "With Genshin/Star Rail CodeEntter, you can quickly input promo codes for Genshin Impact and Honkai Star Rail, and also share a link to this tool :) ChromiumVersion 2.2.2" + "message": "Quick entry of Genshin Impact/Honkai: Star Rail promo codes | 2.2.2.1" }, "submit": { "message": "Submit" @@ -43,5 +43,8 @@ }, "labelBackgroundColor": { "message": "Background Color (if enabled)" + }, + "displayOverlay" :{ + "message": "Link copied" } -} +} \ No newline at end of file diff --git a/chromium/_locales/es/messages.json b/chromium/_locales/es/messages.json index d4d42e2..c59b209 100644 --- a/chromium/_locales/es/messages.json +++ b/chromium/_locales/es/messages.json @@ -1,6 +1,6 @@ { "extensionDescription": { - "message": "Con Genshin/Star Rail CodeEntter, puedes ingresar rápidamente códigos promocionales para Genshin Impact y Honkai Star Rail, ¡y también compartir un enlace a esta herramienta :) ChromiumVersion 2.2.2" + "message": "Entrada rápida de los códigos promocionales de Genshin Impact/Honkai: Star Rail | 2.2.2.1" }, "submit": { "message": "Enviar" @@ -43,5 +43,8 @@ }, "labelBackgroundColor": { "message": "Color de fondo (si está habilitado)" + }, + "displayOverlay" :{ + "message": "Enlace copiado" } -} +} \ No newline at end of file diff --git a/chromium/_locales/jp/messages.json b/chromium/_locales/jp/messages.json index d4d8833..c8cf934 100644 --- a/chromium/_locales/jp/messages.json +++ b/chromium/_locales/jp/messages.json @@ -1,7 +1,4 @@ { - "extensionDescription": { - "message": "Genshin/Star Rail CodeEntterを使用すると、Genshin ImpactおよびHonkai Star Railのプロモコードを素早く入力でき、またこのツールのリンクを共有することもできます :) ChromiumVersion 2.2.2" - }, "submit": { "message": "送信" }, @@ -43,5 +40,8 @@ }, "labelBackgroundColor": { "message": "背景の色(有効になっている場合)" + }, + "displayOverlay" :{ + "message": "コピーされたリンク" } -} +} \ No newline at end of file diff --git a/chromium/_locales/ru/messages.json b/chromium/_locales/ru/messages.json index bc4cb27..7fa1baf 100644 --- a/chromium/_locales/ru/messages.json +++ b/chromium/_locales/ru/messages.json @@ -1,6 +1,6 @@ { "extensionDescription": { - "message": "Благодаря Genshin/Star Rail CodeEntter вы сможете быстро вводить промокоды для Genshin Impact и Honkai Star Rail, a также можете поделиться ссылкой на этот кодик :) ChromiumVersion 2.2.2" + "message": "Быстрый ввод промокодов Genshin Impact/Honkai: Star Rail | 2.2.2.1" }, "submit": { "message": "Ввести" @@ -43,5 +43,8 @@ }, "labelBackgroundColor": { "message": "Цвет фона (если включено)" + }, + "displayOverlay" :{ + "message": "Ссылка скопирована" } -} +} \ No newline at end of file diff --git a/chromium/dailychecker.js b/chromium/dailychecker.js index 9f708b9..4e87950 100644 --- a/chromium/dailychecker.js +++ b/chromium/dailychecker.js @@ -1,47 +1,36 @@ -const HSRHOSTS = [ - { - apiHost: "sg-public-api.hoyolab.com", - page: "act.hoyolab.com/bbs/event/signin/hkrpg/index.html" - } -]; -const HOSTS = [ - { - apiHost: "sg-hk4e-api.hoyolab.com", - page: "act.hoyolab.com/ys/event/signin-sea-v3/index.html" - }, - { - apiHost: "hk4e-api-os.mihoyo.com", - page: "webstatic-sea.mihoyo.com/ys/event/signin-sea/index.html" - } -]; -var currentHSRHosts = HSRHOSTS; -var currentHosts = HOSTS; -var dcwork; +if (typeof browser === "undefined") { + browser = chrome; +} function getCurrDay() { var now = new Date(); now.setMinutes(now.getMinutes() + now.getTimezoneOffset()); now.setHours(now.getHours() + 8); return Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0); } -function request(i, currDay) { - var host = currentHosts[i]; - if (typeof host === "undefined") { - currentHosts = HOSTS; - return; - } - var hsrhost = currentHSRHosts[i]; - if (typeof hsrhost === "undefined") { - currentHSRHosts = HSRHOSTS; - return; - } - fetch("https://" + host.apiHost + "/event/sol/sign?act_id=e202102251931481", { +function GIrequest() { + var currDay = getCurrDay(); + fetch("https://sg-hk4e-api.hoyolab.com/event/sol/sign?act_id=e202102251931481", { method : "POST", headers: { "Content-Type": "application/json" }, credentials: "include" }) - fetch("https://" + hsrhost.apiHost + "/event/luna/os/sign?act_id=e202303301540311", { + .then(response => response.json()) + .then(data => { + 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 { + console.log("GIwarning", data); + } + }) +} +function HSRrequest() { + var currDay = getCurrDay(); + fetch("https://sg-public-api.hoyolab.com/event/luna/os/sign?act_id=e202303301540311", { method : "POST", headers: { "Content-Type": "application/json" @@ -50,41 +39,28 @@ function request(i, currDay) { }) .then(response => response.json()) .then(data => { - if(data.retcode == 0 || data.retcode == -5003) { - chrome.storage.local.set({dc_lastCheked: currDay}); - dcwork = true; - currentHosts = [host]; - currentHSRHosts = [hsrhost]; - console.log("success", data); - } else if(data.retcode == -10002) { - dcwork = false; - console.log("badrequest", data); - request(i + 1); + 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); } else { - console.log("warning", data); - request(i + 1); + console.log("HSRwarning", data); } }) - .catch(error => { - dcwork = false; - console.log("error", error); - request(i + 1); - }); } - function check() { - chrome.storage.local.get({dc_lastCheked: null}).then(storage => { + browser.storage.local.get({dc_lastCheked: null}).then(storage => { var currDay = getCurrDay(); if (storage.dc_lastCheked != currDay) { - request(0, currDay); + HSRrequest(); + GIrequest(); } }); } - -chrome.alarms.onAlarm.addListener(alarm => { +browser.alarms.onAlarm.addListener(alarm => { if (alarm.name == "daily_checker") { check(); } }); - -chrome.alarms.create("daily_checker", {when: Date.now(), periodInMinutes: 1}); \ No newline at end of file +browser.alarms.create("daily_checker", {when: Date.now(), periodInMinutes: 1}); \ No newline at end of file diff --git a/chromium/onlyGi.html b/chromium/onlyGi.html index 1843ae0..7bc1e64 100644 --- a/chromium/onlyGi.html +++ b/chromium/onlyGi.html @@ -43,8 +43,8 @@ justify-content: space-between; } #submit, #share { - width: 140px; - margin: 5px; + width: 48%; + margin-top: 10px; } button { cursor: pointer; @@ -72,17 +72,32 @@ border: none; z-index: 2; } + #displayOverlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.5); + color: white; + display: none; + justify-content: center; + align-items: center; + z-index: 2; + font-family: 'SDK_SC_Web'; + }