Last active
May 17, 2023 11:03
-
-
Save amirofski/b60d3076e9cdfa981b1c9ceee744aa38 to your computer and use it in GitHub Desktop.
JavaScript code to automatically like Twitter posts, Just Run in Browser console when explorering any twitter pages you want to like posts
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
// Replace 'tags' with the desired hashtag | |
var hashtag = 'tags'; | |
// Replace 'count' with the number of tweets you want to like.Be careful of being limited. Max 10 | |
var count = 10; | |
// Function to start liking tweets | |
function startLikingTweets() { | |
// Get the list of tweets | |
var tweets = document.querySelectorAll('[data-testid="like"]'); | |
// Iterate over the tweets and like them | |
for (var i = 0; i < tweets.length && count > 0; i++) { | |
// Check if the tweet is already liked | |
var isLiked = tweets[i].getAttribute('aria-pressed') === 'true'; | |
// If the tweet is not already liked, simulate a click event | |
if (!isLiked) { | |
simulateClick(tweets[i]); | |
console.log('Liked tweet ' + (i + 1)); | |
count--; | |
} | |
} | |
console.log('Liked ' + (10 - count) + ' tweets.'); | |
// Check if there are more tweets to like | |
if (count > 0) { | |
// Scroll down the page to load more tweets | |
window.scrollTo(0, document.body.scrollHeight); | |
// Wait for the page to load and continue liking tweets | |
setTimeout(startLikingTweets, 2000); // Adjust the delay as needed. My Account Blocked :( | |
} | |
} | |
// Function to simulate a click event | |
function simulateClick(element) { | |
var event = new MouseEvent('click', { | |
bubbles: true, | |
cancelable: true, | |
view: window | |
}); | |
element.dispatchEvent(event); | |
} | |
// Start liking tweets | |
startLikingTweets(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment