Skip to content

Commit

Permalink
Copy notification improved
Browse files Browse the repository at this point in the history
This update does not carry a new version of the extension
  • Loading branch information
Kajitsy authored Jan 16, 2024
1 parent c5f1eab commit af32de6
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 122 deletions.
7 changes: 5 additions & 2 deletions chromium/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -43,5 +43,8 @@
},
"labelBackgroundColor": {
"message": "Background Color (if enabled)"
},
"displayOverlay" :{
"message": "Link copied"
}
}
}
7 changes: 5 additions & 2 deletions chromium/_locales/es/messages.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -43,5 +43,8 @@
},
"labelBackgroundColor": {
"message": "Color de fondo (si está habilitado)"
},
"displayOverlay" :{
"message": "Enlace copiado"
}
}
}
8 changes: 4 additions & 4 deletions chromium/_locales/jp/messages.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"extensionDescription": {
"message": "Genshin/Star Rail CodeEntterを使用すると、Genshin ImpactおよびHonkai Star Railのプロモコードを素早く入力でき、またこのツールのリンクを共有することもできます :) ChromiumVersion 2.2.2"
},
"submit": {
"message": "送信"
},
Expand Down Expand Up @@ -43,5 +40,8 @@
},
"labelBackgroundColor": {
"message": "背景の色(有効になっている場合)"
},
"displayOverlay" :{
"message": "コピーされたリンク"
}
}
}
7 changes: 5 additions & 2 deletions chromium/_locales/ru/messages.json
Original file line number Diff line number Diff line change
@@ -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": "Ввести"
Expand Down Expand Up @@ -43,5 +43,8 @@
},
"labelBackgroundColor": {
"message": "Цвет фона (если включено)"
},
"displayOverlay" :{
"message": "Ссылка скопирована"
}
}
}
88 changes: 32 additions & 56 deletions chromium/dailychecker.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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});
browser.alarms.create("daily_checker", {when: Date.now(), periodInMinutes: 1});
21 changes: 18 additions & 3 deletions chromium/onlyGi.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
justify-content: space-between;
}
#submit, #share {
width: 140px;
margin: 5px;
width: 48%;
margin-top: 10px;
}
button {
cursor: pointer;
Expand Down Expand Up @@ -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';
}
</style>
</head>
<body>
<div id="input-container">
<input type="text" id="code" placeholder="Enter code here">
<input type="text" id="code">
</div>
<div id="buttons-container">
<button id="submit">__MSG_submit__</button>
<button id="share">__MSG_share__</button>
</div>
<iframe id="frame" src="" width="756" height="550" style="display: none;"></iframe>
<div id="displayOverlay"></div>
<script src="onlyGi.js"></script>
</body>
</html>
16 changes: 2 additions & 14 deletions chromium/onlyGi.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,10 @@ if (typeof browser === "undefined") {
});

function displayOverlay() {
const overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = 0;
overlay.style.left = 0;
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
overlay.style.color = 'white';
overlay.style.display = 'flex';
overlay.style.justifyContent = 'center';
overlay.style.alignItems = 'center';
overlay.style.fontSize = '1em';
overlay.textContent = 'The Link Has Been Copied';
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);
Expand Down
21 changes: 18 additions & 3 deletions chromium/onlyHsr.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
font-family: 'SDK_SC_Web';
}
#submit, #share {
width: 140px;
margin: 5px;
width: 48%;
margin-top: 10px;
}
button {
cursor: pointer;
Expand Down Expand Up @@ -73,17 +73,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';
}
</style>
</head>
<body>
<div id="input-container">
<input type="text" id="code" placeholder="Enter code here">
<input type="text" id="code">
</div>
<div id="buttons-container">
<button id="submit">__MSG_submit__</button>
<button id="share">__MSG_share__</button>
</div>
<iframe id="frame" src="" width="756" height="550" style="display: none;"></iframe>
<div id="displayOverlay"></div>
<script src="onlyHsr.js"></script>
</body>
</html>
16 changes: 2 additions & 14 deletions chromium/onlyHsr.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,10 @@ if (typeof browser === "undefined") {
});

function displayOverlay() {
const overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = 0;
overlay.style.left = 0;
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
overlay.style.color = 'white';
overlay.style.display = 'flex';
overlay.style.justifyContent = 'center';
overlay.style.alignItems = 'center';
overlay.style.fontSize = '1em';
overlay.textContent = 'The Link Has Been Copied';
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);
Expand Down
5 changes: 2 additions & 3 deletions chromium/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ function showSettingsSection(section) {
function updateDcWorkIconColor() {
if (dcwork = true) {
dcWorkIcon.style.backgroundColor = 'green';
} else if (dcwork = false) {
}
else {
dcWorkIcon.style.backgroundColor = 'red';
} else {
dcWorkIcon.style.backgroundColor = 'yellow';
}
}
function updateIconColorOnChange() {
Expand Down
Loading

0 comments on commit af32de6

Please sign in to comment.