|
316 | 316 | * @namespace GC |
317 | 317 | * @description Namespace containing functions related to Garmin Connect integration. |
318 | 318 | * @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. |
320 | 320 | * @property {function} createGarminButton - Creates a new kudos button for Garmin. |
321 | 321 | * @property {function} garminKudoAllHandler - Handles the "kudo all" action on Garmin. |
322 | 322 | * @property {function} executeGarmin - Executes the Garmin integration logic. |
|
412 | 412 | const icons = findGarminKudosButtons(); // Find all kudos buttons |
413 | 413 | console.log('Garmin: Clicking all kudos buttons, count:', icons.length); // Log the number of kudos buttons |
414 | 414 |
|
| 415 | + let likedCount = 0; // Counter for the number of items liked |
| 416 | + |
415 | 417 | icons.forEach((item) => { |
416 | 418 | // Click all kudos buttons |
417 | 419 | if (item) { |
418 | | - // If the kudos button exists |
419 | 420 | item.click(); // Click the kudos button |
| 421 | + likedCount++; // Increment the counter |
420 | 422 | } |
421 | 423 | }); |
| 424 | + |
| 425 | + // Show a popup with the number of items liked |
| 426 | + showPopup(`You liked ${likedCount} activities!`); |
422 | 427 | } |
423 | 428 |
|
424 | 429 | /** |
|
541 | 546 | } |
542 | 547 | }; |
543 | 548 |
|
| 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 | + |
544 | 572 | /** |
545 | 573 | * Function to get localized message |
546 | 574 | * @param {string} messageName - The name of the message to retrieve. |
|
0 commit comments