Created
October 2, 2023 07:55
-
-
Save pookdeveloper/8db023966cedb67d4c653a727463487d to your computer and use it in GitHub Desktop.
strava auto kudos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Strava Auto Kudos | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Automatically like Strava posts. | |
// @author You | |
// @match https://www.strava.com/dashboard | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=strava.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const avatar = document.querySelector('.avatar-img').src; | |
const getCards = () => document.querySelectorAll('[data-testid="web-feed-entry"]'); | |
let scrollTimeout; | |
const handleScroll = () => { | |
if (scrollTimeout) { | |
clearTimeout(scrollTimeout); | |
} | |
scrollTimeout = setTimeout(() => { | |
clickPosts(); | |
}, 2000); | |
}; | |
const clickPosts = async () => { | |
let cards = getCards(); | |
cards.forEach(card => { | |
const botonKudos = card.querySelector('[data-testid="kudos_button"]'); | |
const imagenCabecera = card.querySelector('[data-testid="owner-avatar"]'); | |
if (imagenCabecera && botonKudos) { | |
const imgElement = imagenCabecera.querySelector('img').src; | |
if (avatar !== imgElement) { | |
const elementosUnfilledKudos = botonKudos.querySelector('[data-testid="unfilled_kudos"]'); | |
if (elementosUnfilledKudos) { | |
console.log('elementoUnfilledKudos============>', elementosUnfilledKudos); | |
botonKudos.click(); | |
} | |
} | |
} | |
}); | |
}; | |
// Agrega un evento onload con un retraso de 2 segundos | |
window.addEventListener('scroll', handleScroll); | |
window.onload = () => { | |
setTimeout(() => { | |
clickPosts(); | |
// Agrega un event listener para el evento scroll | |
}, 2000); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment