Skip to content

Conversation

@kubaam
Copy link

@kubaam kubaam commented Aug 7, 2025

diff --git a/css/style.css b/css/style.css
index fcafe02b5d226c7aab66203589e10d4446922e05..d7af1d9e0e160f419f01d7795b32db42827640b9 100644
--- a/css/style.css
+++ b/css/style.css
@@ -137,50 +137,66 @@ input:checked + .slider:before {
.slider.round:before {
border-radius: 50%;
}

label.caseCard div {
opacity: 0.8;
filter: grayscale(0.8);
transition: all 0.5s;
}

label.caseCard div:hover {
filter: grayscale(0);
opacity: 1;
}

input:checked + .caseData {
filter: grayscale(0);
border: 1px solid goldenrod;
opacity: 1;
}

a.playersData {
transition: all 0.5s;
}

+.kdp-progress-container {

  • width: 100%;
  • background-color: #24242d;
  • border-radius: 4px;
  • overflow: hidden;
  • height: 4px;
  • margin-top: 2px;
    +}

+.kdp-progress-bar {

  • height: 100%;
  • width: 0%;
  • background-color: #ffff85;
  • transition: width 0.5s linear;
    +}

input:checked + .playersData {
border: 1px solid rgb(220 174 100);
background-color: rgb(25 24 30);
}

div.group.relative.flex.w-full.select-none.flex-col.items-center.justify-between.rounded-lg.border.border-solid.border-navy-500.bg-navy-600.bg-cover.bg-center.cursor-pointer
div.relative.flex-1.css-lx3yvj {
position: initial;
}

.steam-price, .skinport-price {
z-index: 2;
}

.steam-price-icon, .skinport-price-icon, .keydrop-price-icon {
display: inline-block;
width: 10px;
margin-top: -3px;
margin-right: 5px;
}

.steam-price-icon {
content: url("https://github.com/Juzlus/KeydropPlus/blob/main/data/icons/steam_Icon.png?raw=true");
}

diff --git a/js/dailyCaseTimer.js b/js/dailyCaseTimer.js
index 55d6ac9a939d58b48ca1ad4ffe5bcbcaaab6b10d..1440f30fcfd8d123dde14aec91d3b3dd4944d921 100644
--- a/js/dailyCaseTimer.js
+++ b/js/dailyCaseTimer.js
@@ -1,71 +1,104 @@
+const renderDailyCaseTimer = (langText) => {

  • $('div[data-testid="header-balance-div"]')
  •    ?.eq(0)
    
  •        ?.prepend($(document?.createElement('div'))
    
  •            ?.addClass('flex h-full items-center gap-x-3 lg:pl-4 lg:pr-4')
    
  •            ?.css({ 'margin-right': '-24px', background: 'rgb(37 37 45)', 'padding-right': '30px' })
    
  •            ?.html(`
    
  •                <div class="flex h-9 w-9 items-center justify-center rounded-lg bg-[#110515]">
    
  •                    <svg class="icon h-4 w-4 flex-shrink-0 text-lightgreen lg:h-5 lg:w-5" viewBox="0 0 22 19" fill="currentColor">
    
  •                        <use xlink:href="https://key-drop.com/web/KD/static/icons.svg?39#box" style="color: #ffff85;"></use>
    
  •                    </svg>
    
  •                </div>
    
  •                <div>
    
  •                    <p class="text-xs font-bold tabular-nums text-lightgreen lg:text-sm">
    
  •                        <a href="/daily-case"><span id="dailyCaseTimer" style="color: #ffff85;">00:00:00</span></a>
    
  •                    </p>
    
  •                    <div id="dailyCaseProgressContainer" class="kdp-progress-container">
    
  •                        <div id="dailyCaseProgressBar" class="kdp-progress-bar"></div>
    
  •                    </div>
    
  •                    <p class="whitespace-nowrap text-2xs font-semibold uppercase leading-none tracking-wider">${langText?.dailyCase}</p>
    
  •                </div>`)
    
  •        )
    
  •        .end();
    

+};
+
const getFreeCaseTimer = async(update) => {
const config = await getConfigData();
if(!config?.active) return;
const language = await getLanguageData(config?.lang);
const fetch = await fetchUrl('GET', "https://key-drop.com/en/apiData/DailyFree/index");

 const langText = {
     waitTime: language?.dailyCase_waitTime,
     readyTime: language?.dailyCase_readyTime,
     dailyCase: language?.dailyCase_dailyCase
 };

 if(!fetch) return;
 const dailyCaseData = {
     deadlineTimestamp: fetch?.init?.levels[0]?.deadlineTimestamp,
     isAvailable: fetch?.init?.levels[0]?.isAvailable,
  •    completed: fetch?.init?.levels[0]?.tasks[0]?.completed
    
  • }
  •    completed: fetch?.init?.levels[0]?.tasks[0]?.completed,
    
  •    totalDuration: 24 * 60 * 60 * 1000
    
  • };
    if(!dailyCaseData?.completed) return;

    if(!update)

  •    $('div[data-testid="header-balance-div"]')
    
  •            ?.eq(0)
    
  •                ?.prepend($(document?.createElement('div'))
    
  •                    ?.addClass('flex h-full items-center gap-x-3 lg:pl-4 lg:pr-4')
    
  •                    ?.css({ 'margin-right': '-24px', background: 'rgb(37 37 45)', 'padding-right': '30px' })
    
  •                    ?.html(`<div class="flex h-9 w-9 items-center justify-center rounded-lg bg-[#110515]"><svg class="icon h-4 w-4 flex-shrink-0 text-lightgreen lg:h-5 lg:w-5" viewBox="0 0 22 19" fill="currentColor"><use xlink:href="https://key-drop.com/web/KD/static/icons.svg?39#box" style="color: #ffff85;"></use></svg></div><div><p class="text-xs font-bold tabular-nums text-lightgreen lg:text-sm"><a href="/daily-case"><span id="dailyCaseTimer" style="color: #ffff85;">00:00:00</span></a></p><p class="whitespace-nowrap text-2xs font-semibold uppercase leading-none tracking-wider">${langText?.dailyCase}</p></div>`)
    
  •                )
    
  •                .end();
    
  •    renderDailyCaseTimer(langText);
    

    const refreshInterval = setInterval(() => {
    refreshTime(dailyCaseData, langText, refreshInterval);
    }, 1000);
    };

const refreshTime = (dailyCaseData, langText, refreshInterval) => {

  • if(dailyCaseData?.deadlineTimestamp <= new Date()?.getTime()) {
  • const now = new Date()?.getTime();
  • const remaining = dailyCaseData?.deadlineTimestamp - now;
  • if(remaining <= 0) {
    dailyCaseData.isAvailable = true;
    clearInterval(refreshInterval);
    setTimeout(() => {
    //openFreeCase(langText);
    getFreeCaseTimer(true);
    }, Math.floor(((Math.random() * 2) + 2) * 60 * 1000) );
    }
  • const date = dailyCaseData?.isAvailable ? null : new Date(dailyCaseData?.deadlineTimestamp - new Date()?.getTime());
  • $('#dailyCaseTimer')?.text(dailyCaseData?.isAvailable ? langText?.readyTime : ${langText?.waitTime} ${date?.getHours() == 0 ? 23:${date.getHours()-1 > 9 ? date.getHours()-1 : 0${date.getHours()-1}}}:${date.getMinutes() > 9 ? date.getMinutes() : 0${date.getMinutes()}}:${date.getSeconds() > 9 ? date.getSeconds() : 0${date.getSeconds()}});
  • const hours = Math.floor(remaining / (1000 * 60 * 60));
  • const minutes = Math.floor((remaining % (1000 * 60 * 60)) / (1000 * 60));
  • const seconds = Math.floor((remaining % (1000 * 60)) / 1000);
  • $('#dailyCaseTimer')?.text(
  •    dailyCaseData?.isAvailable
    
  •        ? langText?.readyTime
    
  •        : `${langText?.waitTime} ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
    
  • );
  • const progress = Math.min(1, Math.max(0, 1 - (remaining / dailyCaseData.totalDuration)));
  • $('#dailyCaseProgressBar')?.css('width', ${(progress * 100).toFixed(2)}%);
    };

const createSkinsValueDiv = async() => {
setTimeout(async () => {
const config = await getConfigData();
if(!config?.active) return;
const server = await getServerData();

     if(!server?.skinsValueEnable) return getFreeCaseTimer();
     const language = await getLanguageData(config?.lang);

     const langText = {
         skinsValue: language?.dailyCase_skinsValue || "Wartość skinów"
     };

     const fetch = await fetchUrl("GET", "https://key-drop.com/en/panel/profil/eq_value");
     if(!fetch) return;
     const data = JSON.parse(fetch);
     const skinsValue = `${(data?.fullPrice).toFixed(2).toString().replace('.',',')} ${data?.currency}`;

     $('div[data-testid="balance"]')
     ?.eq(0)
         ?.prepend($(document?.createElement('div'))
             ?.addClass('flex items-center gap-x-2')
             ?.html(`<div class="flex h-9 w-9 items-center justify-center rounded-lg bg-[#110515]"><svg class="icon h-4 w-4 flex-shrink-0 text-lightgreen lg:h-5 lg:w-5" viewBox="0 0 22 19" fill="currentColor"><use xlink:href="https://key-drop.com/web/KD/static/icons.svg?39#gun" style="color: #b585ff;"></use></svg></div><div><p class="text-xs font-bold tabular-nums text-lightgreen lg:text-sm"><span id="skinsValueText" style="color: #b585ff;">${skinsValue}</span></p><p class="whitespace-nowrap text-2xs font-semibold uppercase leading-none tracking-wider">${langText?.skinsValue}</p></div>`)

kubaam added 10 commits August 7, 2025 05:31
…de-structure

Refactor settings panel toggle handling and improve language selector UI
…-for-giveaway-join

feat: add advanced giveaway search options
…-and-code-structure

Refactor settings panel toggle handling and improve language selector UI
…nhance-functions

refactor: enhance utility functions
…mprove-functions

refactor: enhance utilities and fetch accuracy
@Juzlus
Copy link
Owner

Juzlus commented Aug 8, 2025

Hello, and thank you for the pull request!
There are a few issues:

  • The fetch function does not work correctly in this context. It needs to be used with jQuery AJAX or called from the background script; otherwise, it fails to execute properly.

  • The Content-Type header is unreliable in most cases. Many responses are not correctly marked as JSON, so using it to detect the format causes problems.

  • Setting the pages parameter when joining giveaways is unnecessary. There is never any data beyond the first page since itemsPerPage is already greater than the number of active KeyDrop giveaways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants