Every function with real, working examples.
// Simple tweet
await XActions.tweet.post("Hello world! 🌍")
// Daily motivation poster
const quotes = ["Stay focused! 💪", "Keep building! 🚀", "Never give up! 🔥"]
await XActions.tweet.post(quotes[Math.floor(Math.random() * quotes.length)])
// Announcement with emoji
await XActions.tweet.post("🚀 Just launched our new feature! Check it out at example.com")// Reply to first visible tweet
const tweets = XActions.tweet.getAll()
await XActions.tweet.reply(tweets[0], "Great insight! Thanks for sharing 🙏")
// Auto-reply to tweets with keywords
const tweets = XActions.tweet.getAll()
for (const tweet of tweets) {
const text = tweet.querySelector('[data-testid="tweetText"]')?.textContent || ""
if (text.toLowerCase().includes("help")) {
await XActions.tweet.reply(tweet, "Happy to help! DM me for more details.")
break
}
}// Quote with commentary
const tweets = XActions.tweet.getAll()
await XActions.tweet.quote(tweets[0], "This is exactly what I've been saying! 👆")
// Quote to amplify
const tweet = XActions.tweet.getAll()[0]
await XActions.tweet.quote(tweet, "Everyone needs to see this 📢")// Delete first tweet (must be yours)
const tweets = XActions.tweet.getAll()
await XActions.tweet.delete(tweets[0])
// Bulk delete (use carefully!)
async function deleteMyTweets(count = 5) {
for (let i = 0; i < count; i++) {
const tweets = XActions.tweet.getAll()
if (tweets.length === 0) break
await XActions.tweet.delete(tweets[0])
await new Promise(r => setTimeout(r, 2000))
}
}// Pin your best tweet
const tweets = XActions.tweet.getAll()
await XActions.tweet.pin(tweets[0])// Get ID of first tweet
const tweets = XActions.tweet.getAll()
const id = XActions.tweet.getId(tweets[0])
console.log("Tweet URL: https://x.com/i/status/" + id)
// Collect all tweet IDs on page
const ids = XActions.tweet.getAll().map(t => XActions.tweet.getId(t))
console.log("Found IDs:", ids)// Count tweets
const tweets = XActions.tweet.getAll()
console.log(`${tweets.length} tweets on page`)
// Find tweets with keyword
const aiTweets = XActions.tweet.getAll().filter(t => {
const text = t.querySelector('[data-testid="tweetText"]')?.textContent || ""
return text.toLowerCase().includes("ai")
})
console.log(`Found ${aiTweets.length} AI tweets`)// Educational thread
await XActions.tweet.thread([
"🧵 5 JavaScript tips you need to know:",
"1/ Use const by default, let when needed",
"2/ Arrow functions inherit 'this' from parent",
"3/ Template literals are cleaner than concatenation",
"4/ async/await beats .then() chains",
"5/ Destructuring saves lines of code",
"Follow for more tips! 👋"
])// Like first tweet
const tweets = XActions.tweet.getAll()
await XActions.engage.like(tweets[0])
// Like first 10 tweets
for (const tweet of XActions.tweet.getAll().slice(0, 10)) {
await XActions.engage.like(tweet)
await new Promise(r => setTimeout(r, 500))
}
// Like tweets with keyword
async function likeByKeyword(keyword, max = 5) {
let count = 0
for (const tweet of XActions.tweet.getAll()) {
if (count >= max) break
const text = tweet.querySelector('[data-testid="tweetText"]')?.textContent || ""
if (text.toLowerCase().includes(keyword)) {
await XActions.engage.like(tweet)
count++
}
}
console.log(`Liked ${count} tweets with "${keyword}"`)
}
await likeByKeyword("web3", 5)const tweets = XActions.tweet.getAll()
await XActions.engage.unlike(tweets[0])// Retweet first tweet
const tweets = XActions.tweet.getAll()
await XActions.engage.retweet(tweets[0])
// Like + Retweet combo
async function boost(tweet) {
await XActions.engage.like(tweet)
await XActions.engage.retweet(tweet)
}
await boost(XActions.tweet.getAll()[0])const tweets = XActions.tweet.getAll()
await XActions.engage.unretweet(tweets[0])// Bookmark first tweet
await XActions.engage.bookmark(XActions.tweet.getAll()[0])
// Bookmark tweets with links
for (const tweet of XActions.tweet.getAll()) {
if (tweet.querySelector('a[href*="t.co"]')) {
await XActions.engage.bookmark(tweet)
}
}await XActions.engage.unbookmark(XActions.tweet.getAll()[0])await XActions.engage.addToList(XActions.tweet.getAll()[0], "Interesting People")await XActions.engage.report(XActions.tweet.getAll()[0])
// Dialog opens - select reason manuallyawait XActions.engage.copyLink(XActions.tweet.getAll()[0])
console.log("Link copied to clipboard!")await XActions.engage.shareViaDM(XActions.tweet.getAll()[0], "friendname")await XActions.engage.embed(XActions.tweet.getAll()[0])
// Copy embed code from dialogawait XActions.engage.viewAnalytics(XActions.tweet.getAll()[0])await XActions.engage.requestNote(XActions.tweet.getAll()[0])await XActions.engage.highlight(XActions.tweet.getAll()[0])// By username
await XActions.user.follow("elonmusk")
// Follow list of users
const users = ["openai", "anthropic", "google"]
for (const u of users) {
await XActions.user.follow(u)
await new Promise(r => setTimeout(r, 2000))
}await XActions.user.unfollow("someuser")await XActions.user.block("spammer")
// Block multiple
for (const spam of ["spam1", "spam2"]) {
await XActions.user.block(spam)
}await XActions.user.unblock("formerlyblocked")await XActions.user.mute("annoying")await XActions.user.unmute("previouslymuted")await XActions.user.report("badactor")await XActions.user.addToList("techwriter", "Tech News")
// Build curated list
const leaders = ["paulg", "naval", "sama"]
for (const l of leaders) {
await XActions.user.addToList(l, "Founders")
}await XActions.user.notifyOn("mustwatchaccount")await XActions.user.notifyOff("toofrequent")await XActions.user.viewTopics("influencer")await XActions.user.viewLists("curator")await XActions.user.viewFollowers("competitor")await XActions.user.viewFollowing("tastemaker")await XActions.user.viewLikes("researcher")await XActions.user.viewMedia("photographer")await XActions.user.viewReplies("activeuser")await XActions.user.viewHighlights("creator")await XActions.user.viewArticles("writer")await XActions.user.shareProfile("coolaccount")const follows = await XActions.user.followsYou("someuser")
console.log(follows ? "They follow you!" : "They don't follow you")
// Find mutuals
async function findMutuals(users) {
const mutuals = []
for (const u of users) {
if (await XActions.user.followsYou(u)) mutuals.push(u)
}
return mutuals
}const info = await XActions.user.getInfo("openai")
console.log(`${info.displayName} - ${info.bio}`)
console.log(`Followers: ${info.followers}`)await XActions.user.restrict("limitedinteraction")await XActions.dm.send("friend", "Hey! How are you?")
// Send to multiple
const team = ["member1", "member2"]
for (const m of team) {
await XActions.dm.send(m, "Team meeting at 3pm!")
}await XActions.dm.open("friend")const convos = await XActions.dm.getConversations()
console.log(`You have ${convos.length} conversations`)const convos = await XActions.dm.getConversations()
await XActions.dm.deleteConversation(convos[0].element)await XActions.dm.leaveGroup()await XActions.dm.createGroup(["user1", "user2", "user3"])await XActions.dm.sendImage()
// File picker opens - select manuallyawait XActions.dm.sendGif("celebration")// React with heart
await XActions.dm.react(messageElement, "❤️")await XActions.search.query("javascript tips")
await XActions.search.query("AI news", "live") // Latestawait XActions.search.top("startup advice")await XActions.search.latest("breaking news")await XActions.search.people("web developer")await XActions.search.photos("sunset photography")await XActions.search.videos("coding tutorial")await XActions.search.from("elonmusk")await XActions.search.to("openai")await XActions.search.mentions("yourhandle")await XActions.search.hashtag("buildinpublic")// Viral tweets from a user
await XActions.search.advanced({
from: "elonmusk",
minFaves: 10000,
since: "2024-01-01"
})
// Tech discussions with media
await XActions.search.advanced({
words: "AI startup",
hasMedia: true,
minRetweets: 100,
lang: "en"
})
// Find your mentions (excluding RTs)
await XActions.search.advanced({
mentioning: "yourusername",
excludeRetweets: true
})
// Job postings
await XActions.search.advanced({
words: "hiring",
hashtags: ["remotejobs"],
since: "2024-12-01"
})await XActions.search.query("javascript")
const results = XActions.search.getResults()
console.log(`Found ${results.length} tweets`)await XActions.nav.home()await XActions.nav.explore()await XActions.nav.notifications()await XActions.nav.messages()await XActions.nav.bookmarks()await XActions.nav.lists()await XActions.nav.communities()await XActions.nav.premium()await XActions.nav.profile("elonmusk")
await XActions.nav.profile() // Your own profileawait XActions.nav.settings()await XActions.nav.notifyAll()await XActions.nav.notifyVerified()await XActions.nav.notifyMentions()await XActions.nav.forYou()await XActions.nav.following()await XActions.nav.trending()await XActions.nav.news()await XActions.nav.sports()await XActions.nav.entertainment()await XActions.nav.spaces()XActions.nav.scrollToTop()XActions.nav.scrollToBottom()XActions.nav.scrollBy(500) // Scroll down 500px
XActions.nav.scrollBy(-200) // Scroll up 200pxXActions.nav.back()XActions.nav.forward()XActions.nav.refresh()// Public list
await XActions.lists.create("Tech News", "Best tech journalists", false)
// Private list
await XActions.lists.create("Competitors", "Track competitor accounts", true)await XActions.lists.delete("1234567890")await XActions.lists.edit("1234567890", "Updated Name", "New description")await XActions.lists.follow("1234567890")await XActions.lists.unfollow("1234567890")await XActions.lists.pin("1234567890")const lists = await XActions.lists.getAll()
console.log(`You have ${lists.length} lists`)await XActions.lists.viewMembers("1234567890")await XActions.lists.viewFollowers("1234567890")await XActions.settings.account()await XActions.settings.security()await XActions.settings.privacy()await XActions.settings.notifications()await XActions.settings.accessibility()await XActions.settings.monetization()await XActions.settings.creatorSubs()await XActions.settings.premium()await XActions.settings.mutedAccounts()await XActions.settings.mutedWords()await XActions.settings.blockedAccounts()await XActions.settings.addMutedWord("spoilers")
await XActions.settings.addMutedWord("politics")await XActions.settings.downloadData()await XActions.settings.deactivate()
// Proceed with caution!await XActions.profile.edit()await XActions.profile.updateName("John Doe 🚀")await XActions.profile.updateBio("Building cool stuff | Founder @startup | DMs open")await XActions.profile.updateLocation("San Francisco, CA")await XActions.profile.updateWebsite("https://mywebsite.com")await XActions.profile.updateAvatar()
// File picker opensawait XActions.profile.updateHeader()
// File picker opensawait XActions.profile.switchToProfessional()const me = XActions.utils.getCurrentUser()
console.log(`Logged in as @${me}`)if (XActions.utils.isLoggedIn()) {
console.log("Ready to automate!")
} else {
console.log("Please log in first")
}const tokens = XActions.utils.getTokens()
console.log("CSRF token:", tokens.ct0)
// Useful for API callsconst id = XActions.utils.getTweetIdFromUrl("https://x.com/user/status/123456789")
console.log(id) // "123456789"const user = XActions.utils.getUsernameFromUrl("https://x.com/elonmusk")
console.log(user) // "elonmusk"await XActions.utils.waitForPageLoad()
console.log("Page ready!")await XActions.utils.loadMore(5) // Scroll 5 timesXActions.utils.clearXData()// Export 100 bookmarks
const bookmarks = await XActions.utils.exportBookmarks(100)
console.log(bookmarks)
// Download as JSON
const bookmarks = await XActions.utils.exportBookmarks(500)
const blob = new Blob([JSON.stringify(bookmarks, null, 2)], {type: 'application/json'})
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = 'bookmarks.json'
a.click()const likes = await XActions.utils.exportLikes("myusername", 200)
console.log(`Exported ${likes.length} liked tweets`)await XActions.utils.copyToClipboard("Hello world!")await XActions.utils.screenshotTweet("https://x.com/user/status/123")
// Opens screenshot service in new tabXActions.utils.showKeyboardShortcuts()XActions.utils.devMode()
// All elements outlined with data-testid labelsconst selectors = XActions.utils.getAllSelectors()
console.log(selectors) // Array of all data-testid values on pageawait XActions.spaces.browse()await XActions.spaces.join("1234567890")await XActions.spaces.leave()await XActions.spaces.requestToSpeak()await XActions.spaces.setReminder("1234567890")await XActions.spaces.share()await XActions.communities.browse()await XActions.communities.view("1234567890")await XActions.communities.join("1234567890")await XActions.communities.leave("1234567890")await XActions.communities.post("1234567890", "Hello community! 👋")await XActions.search.query("web3 developer")
await new Promise(r => setTimeout(r, 2000))
const tweets = XActions.tweet.getAll().slice(0, 10)
for (const tweet of tweets) {
await XActions.engage.like(tweet)
await XActions.user.follow(tweet)
await new Promise(r => setTimeout(r, 3000))
}const bookmarks = await XActions.utils.exportBookmarks(1000)
const blob = new Blob([JSON.stringify(bookmarks, null, 2)], {type: 'application/json'})
const a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = `bookmarks-${Date.now()}.json`
a.click()
console.log(`Exported ${bookmarks.length} bookmarks!`)const following = ["user1", "user2", "user3", "user4", "user5"]
const nonMutuals = []
for (const user of following) {
if (!(await XActions.user.followsYou(user))) {
nonMutuals.push(user)
}
await new Promise(r => setTimeout(r, 2000))
}
console.log("Non-mutuals:", nonMutuals)await XActions.search.hashtag("buildinpublic")
await new Promise(r => setTimeout(r, 2000))
for (const tweet of XActions.tweet.getAll().slice(0, 5)) {
await XActions.engage.like(tweet)
await XActions.engage.bookmark(tweet)
await new Promise(r => setTimeout(r, 2000))
}const posts = [
"Good morning! ☀️ What are you building today?",
"Tip of the day: Always test your code before deploying 🧪",
"Evening thought: Consistency beats intensity 💪"
]
for (const post of posts) {
await XActions.tweet.post(post)
// In real usage, you'd schedule these with setTimeout or cron
}