|
const maxButtons = 200; // Its weird going too far back |
|
let delay = 25; // ms delay between clicks |
|
|
|
var buttonsToBeClicked = 0; |
|
const poppy = function() { |
|
const popup = document.createElement("div"); |
|
popup.innerHTML = ` |
|
<div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center;"> |
|
<div style="background: white; padding: 20px; border-radius: 5px; text-align: center;"> |
|
<h2 style="margin: 0 0 10px;">The Kudoz Machina</h2> |
|
<p id="km"></p> |
|
<p id="km2"></p> |
|
<button onclick="this.parentElement.parentElement.remove()">oki!</button> |
|
</div> |
|
</div> |
|
`; |
|
document.body.appendChild(popup); |
|
} |
|
const wr = function(t, id) { |
|
document.getElementById(id).innerHTML = t |
|
} |
|
|
|
poppy() |
|
setTimeout(() => { |
|
let allButtons = document.querySelectorAll('button:where([data-testid="kudos_button"])'); |
|
if (allButtons.length > 0) { |
|
|
|
wr(`Yay - found ${allButtons.length} buttons`, 'km'); |
|
|
|
let buttons = Array.from(allButtons).slice(0, maxButtons); |
|
buttons = buttons.filter(button => ['Be the first to give kudos!', 'Give kudos'].includes(button.title)); |
|
|
|
if (buttons.length == 0) { |
|
wr(`No buttons to lick`, 'km2'); |
|
} else { |
|
|
|
buttons.forEach((node, i) => { |
|
buttonsToBeClicked++; |
|
setTimeout(() => { |
|
wr(`Kudozing item ${i + 1} of ${buttonsToBeClicked}`, 'km2'); |
|
node.click(); |
|
if (i + 1 == buttonsToBeClicked) { |
|
wr(`Gave ${buttonsToBeClicked} kudoz`, 'km2'); |
|
} |
|
}, delay * (i + 1)); |
|
}); |
|
wr(`Giving ${buttonsToBeClicked} kudoz for you`, 'km'); |
|
} |
|
} else { |
|
wr("No buttons found") |
|
} |
|
|
|
}, 200) |
|
|
|
//bookmarklet_title: Kudoz |
|
//bookmarklet_about: Bookmarklet for giving all your friends kudos on Strava |