Skip to content

Commit 6f53ede

Browse files
committed
feat: Enhance Garmin integration with like count popup and improved button search
1 parent 5a5cad1 commit 6f53ede

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

KudoAll-Strava-Garmin.user.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
* @namespace GC
317317
* @description Namespace containing functions related to Garmin Connect integration.
318318
* @property {function} getGarminContainer - Retrieves the Garmin container element.
319-
* @property {function} findGarminKudosButtons - Finds all kudos buttons within the Garmin container.
319+
* @property {function} findGarminKudosButtons - Finds Garmin kudos buttons within a specified container or the entire document.
320320
* @property {function} createGarminButton - Creates a new kudos button for Garmin.
321321
* @property {function} garminKudoAllHandler - Handles the "kudo all" action on Garmin.
322322
* @property {function} executeGarmin - Executes the Garmin integration logic.
@@ -412,13 +412,18 @@
412412
const icons = findGarminKudosButtons(); // Find all kudos buttons
413413
console.log('Garmin: Clicking all kudos buttons, count:', icons.length); // Log the number of kudos buttons
414414

415+
let likedCount = 0; // Counter for the number of items liked
416+
415417
icons.forEach((item) => {
416418
// Click all kudos buttons
417419
if (item) {
418-
// If the kudos button exists
419420
item.click(); // Click the kudos button
421+
likedCount++; // Increment the counter
420422
}
421423
});
424+
425+
// Show a popup with the number of items liked
426+
showPopup(`You liked ${likedCount} activities!`);
422427
}
423428

424429
/**
@@ -541,6 +546,29 @@
541546
}
542547
};
543548

549+
function showPopup(message) {
550+
const popup = document.createElement('div');
551+
popup.textContent = message;
552+
popup.style = `
553+
position: fixed;
554+
top: 20px;
555+
right: 20px;
556+
background-color: #2ea44f;
557+
color: white;
558+
padding: 10px 20px;
559+
border-radius: 5px;
560+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
561+
z-index: 1000;
562+
font-size: 16px;
563+
`;
564+
document.body.appendChild(popup);
565+
566+
// Automatically remove the popup after 3 seconds
567+
setTimeout(() => {
568+
popup.remove();
569+
}, 3000);
570+
}
571+
544572
/**
545573
* Function to get localized message
546574
* @param {string} messageName - The name of the message to retrieve.

0 commit comments

Comments
 (0)