Skip to content

Commit 89c3818

Browse files
committed
feat: Update version to 2.2 and enhance button interactions with hover and click effects
1 parent 9b7d906 commit 89c3818

1 file changed

Lines changed: 78 additions & 2 deletions

File tree

KudoAll-Strava-Garmin.user.js

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Strava and Garmin Kudos All (Working)
33
// @namespace typpi.online
4-
// @version 2.1.1
4+
// @version 2.2
55
// @description Adds a button to give kudos to all visible activities on Strava and Garmin Connect.
66
// @author Nick2bad4u
77
// @license Unlicense
@@ -301,6 +301,32 @@
301301
navItemA.append(navItemText); // Append the text to the button link
302302
navItemLi.append(navItemA); // Append the link to the button
303303

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+
304330
return navItemLi; // Return the button element
305331
}
306332

@@ -317,14 +343,20 @@
317343
const icons = getStravaKudosButtons(); // Get the Strava kudos buttons
318344
console.log('Strava: Clicking all kudos buttons, count:', icons.length); // Log the number of kudos buttons
319345

346+
let likedCount = 0; // Counter for the number of items liked
347+
320348
icons.forEach((item) => {
321349
// Click all kudos buttons
322350
const parentItem = item?.parentElement; // Get the parent element of the kudos button
323351
if (parentItem) {
324352
// If the parent element exists
325353
parentItem.click(); // Click the parent element
354+
likedCount++; // Increment the counter
326355
}
327356
});
357+
358+
// Show a popup with the number of items liked
359+
showPopup(`You gave kudos 👍 to ${likedCount} activities!`);
328360
}
329361

330362
/**
@@ -427,6 +459,50 @@
427459
link.setAttribute('aria-label', label); // Set the button link aria-label
428460
link.setAttribute('data-original-title', label); // Set the button link data-original-title
429461
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+
430506
return link;
431507
}
432508

@@ -462,7 +538,7 @@
462538
});
463539

464540
// Show a popup with the number of items liked
465-
showPopup(`You liked ${likedCount} activities!`);
541+
showPopup(`You gave hearts ❤️ to ${likedCount} activities!`);
466542
}
467543

468544
/**

0 commit comments

Comments
 (0)