Skip to content

Commit

Permalink
2.2.4 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajitsy committed Jan 20, 2024
1 parent c39b466 commit dfdd61d
Show file tree
Hide file tree
Showing 32 changed files with 453 additions and 358 deletions.
5 changes: 4 additions & 1 deletion chromium/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -62,6 +62,9 @@
"labelRounding": {
"message": "Disable roundings"
},
"labelIcon": {
"message": "Disable icon change"
},
"labelSnow": {
"message": "Turn off the snowfall"
}
Expand Down
5 changes: 4 additions & 1 deletion chromium/_locales/es/messages.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -62,6 +62,9 @@
"labelRounding": {
"message": "Desactivar el redondeo"
},
"labelIcon": {
"message": "Desactivar el cambio de icono"
},
"labelSnow": {
"message": "Apagar la nevada"
}
Expand Down
3 changes: 3 additions & 0 deletions chromium/_locales/jp/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"labelRounding": {
"message": "丸めを無効にする"
},
"labelIcon": {
"message": "アイコンの変更を無効にする"
},
"labelSnow": {
"message": "降雪のスイッチを切る"
}
Expand Down
5 changes: 4 additions & 1 deletion chromium/_locales/ru/messages.json
Original file line number Diff line number Diff line change
@@ -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": "Ввести"
Expand Down Expand Up @@ -62,6 +62,9 @@
"labelRounding": {
"message": "Отключить закругления"
},
"labelIcon": {
"message": "Отключить смену иконок"
},
"labelSnow": {
"message": "Отключить снегопад"
}
Expand Down
41 changes: 36 additions & 5 deletions chromium/dailychecker.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
if (typeof browser === "undefined") {
browser = chrome;
browser.browserAction = chrome.action;
}
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);
}
var HSRwork;
var GIwork;
function GIrequest() {
var currDay = getCurrDay();
fetch("https://sg-hk4e-api.hoyolab.com/event/sol/sign?act_id=e202102251931481", {
Expand All @@ -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();
Expand All @@ -42,19 +50,42 @@ 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 => {
var currDay = getCurrDay();
if (storage.dc_lastCheked != currDay) {
HSRrequest();
GIrequest();
setTimeout(icon, 5000);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion chromium/manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 1 addition & 3 deletions chromium/onlyGi.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
background-repeat: no-repeat;
background-position: center;
overflow: hidden;
width: 170vh;
}
#input-container {
display: flex;
Expand Down Expand Up @@ -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;
Expand Down
85 changes: 24 additions & 61 deletions chromium/onlyGi.js
Original file line number Diff line number Diff line change
@@ -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);
}
Expand All @@ -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');
});
2 changes: 0 additions & 2 deletions chromium/onlyHsr.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
background-repeat: no-repeat;
background-position: center;
overflow: hidden;
width: 170vh;
}
#input-container {
display: flex;
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit dfdd61d

Please sign in to comment.