|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Strava and Garmin Kudos All (Working) |
3 | 3 | // @namespace typpi.online |
4 | | -// @version 2.1.1 |
| 4 | +// @version 2.2 |
5 | 5 | // @description Adds a button to give kudos to all visible activities on Strava and Garmin Connect. |
6 | 6 | // @author Nick2bad4u |
7 | 7 | // @license Unlicense |
|
301 | 301 | navItemA.append(navItemText); // Append the text to the button link |
302 | 302 | navItemLi.append(navItemA); // Append the link to the button |
303 | 303 |
|
| 304 | + // Add hover effect |
| 305 | + navItemA.addEventListener('mouseover', () => { |
| 306 | + navItemA.style.backgroundColor = '#2ea44f'; // Change background color on hover |
| 307 | + navItemA.style.color = 'white'; // Change text color on hover |
| 308 | + navItemA.style.transform = 'scale(1.1)'; // Slightly enlarge the button on hover |
| 309 | + navItemA.style.transition = 'all 0.3s ease'; // Smooth transition for the effects |
| 310 | + navItemA.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)'; // Add a shadow effect |
| 311 | + }); |
| 312 | + |
| 313 | + navItemA.addEventListener('mouseout', () => { |
| 314 | + navItemA.style.backgroundColor = ''; // Reset background color |
| 315 | + navItemA.style.color = ''; // Reset text color |
| 316 | + navItemA.style.transform = 'scale(1)'; // Reset size |
| 317 | + navItemA.style.boxShadow = ''; // Remove shadow |
| 318 | + }); |
| 319 | + |
| 320 | + // Add click effect |
| 321 | + navItemA.addEventListener('click', () => { |
| 322 | + navItemA.style.transform = 'scale(0.95)'; // Shrink the button slightly on click |
| 323 | + navItemA.style.opacity = '0.9'; // Slightly fade the button on click |
| 324 | + setTimeout(() => { |
| 325 | + navItemA.style.transform = 'scale(1)'; // Reset size after click effect |
| 326 | + navItemA.style.opacity = '1'; // Reset opacity after click effect |
| 327 | + }, 150); // Duration of the click effect |
| 328 | + }); |
| 329 | + |
304 | 330 | return navItemLi; // Return the button element |
305 | 331 | } |
306 | 332 |
|
|
317 | 343 | const icons = getStravaKudosButtons(); // Get the Strava kudos buttons |
318 | 344 | console.log('Strava: Clicking all kudos buttons, count:', icons.length); // Log the number of kudos buttons |
319 | 345 |
|
| 346 | + let likedCount = 0; // Counter for the number of items liked |
| 347 | + |
320 | 348 | icons.forEach((item) => { |
321 | 349 | // Click all kudos buttons |
322 | 350 | const parentItem = item?.parentElement; // Get the parent element of the kudos button |
323 | 351 | if (parentItem) { |
324 | 352 | // If the parent element exists |
325 | 353 | parentItem.click(); // Click the parent element |
| 354 | + likedCount++; // Increment the counter |
326 | 355 | } |
327 | 356 | }); |
| 357 | + |
| 358 | + // Show a popup with the number of items liked |
| 359 | + showPopup(`You gave kudos 👍 to ${likedCount} activities!`); |
328 | 360 | } |
329 | 361 |
|
330 | 362 | /** |
|
427 | 459 | link.setAttribute('aria-label', label); // Set the button link aria-label |
428 | 460 | link.setAttribute('data-original-title', label); // Set the button link data-original-title |
429 | 461 | link.setAttribute('data-rel', 'tooltip'); // Set the button link data-rel |
| 462 | + |
| 463 | + // Add hover effect to fill the heart red |
| 464 | + link.addEventListener('mouseover', () => { |
| 465 | + link.style.color = 'red'; // Change the heart color to red on hover |
| 466 | + link.style.transform = 'scale(1.2)'; // Slightly enlarge the heart on hover |
| 467 | + link.style.transition = 'all 0.3s ease'; // Smooth transition for the effects |
| 468 | + link.style.boxShadow = '0 4px 8px rgba(255, 0, 0, 0.5)'; // Add a glowing red shadow |
| 469 | + }); |
| 470 | + link.addEventListener('mouseout', () => { |
| 471 | + link.style.color = ''; // Reset the heart color when not hovering |
| 472 | + link.style.transform = 'scale(1)'; // Reset the size when not hovering |
| 473 | + link.style.boxShadow = ''; // Remove the shadow when not hovering |
| 474 | + }); |
| 475 | + |
| 476 | + // Add click effect to briefly shrink the heart |
| 477 | + link.addEventListener('click', () => { |
| 478 | + link.style.transform = 'scale(0.9)'; // Shrink the heart slightly on click |
| 479 | + link.style.opacity = '0.8'; // Slightly fade the heart on click |
| 480 | + setTimeout(() => { |
| 481 | + link.style.transform = 'scale(1)'; // Reset the size after the click effect |
| 482 | + link.style.opacity = '1'; // Reset the opacity after the click effect |
| 483 | + }, 150); // Duration of the click effect |
| 484 | + }); |
| 485 | + |
| 486 | + // Add a pulsating animation effect |
| 487 | + const pulsateKeyframes = ` |
| 488 | + @keyframes pulsate { |
| 489 | + 0% { transform: scale(1); } |
| 490 | + 50% { transform: scale(1.1); } |
| 491 | + 100% { transform: scale(1); } |
| 492 | + } |
| 493 | + `; |
| 494 | + const styleSheet = document.createElement('style'); |
| 495 | + styleSheet.type = 'text/css'; |
| 496 | + styleSheet.innerText = pulsateKeyframes; |
| 497 | + document.head.appendChild(styleSheet); |
| 498 | + |
| 499 | + link.addEventListener('mouseenter', () => { |
| 500 | + link.style.animation = 'pulsate 1s infinite'; // Start pulsating on hover |
| 501 | + }); |
| 502 | + link.addEventListener('mouseleave', () => { |
| 503 | + link.style.animation = ''; // Stop pulsating when not hovering |
| 504 | + }); |
| 505 | + |
430 | 506 | return link; |
431 | 507 | } |
432 | 508 |
|
|
462 | 538 | }); |
463 | 539 |
|
464 | 540 | // Show a popup with the number of items liked |
465 | | - showPopup(`You liked ${likedCount} activities!`); |
| 541 | + showPopup(`You gave hearts ❤️ to ${likedCount} activities!`); |
466 | 542 | } |
467 | 543 |
|
468 | 544 | /** |
|
0 commit comments