Skip to content

Commit

Permalink
refactor: remove launcher services, replace twitter.com to x.com
Browse files Browse the repository at this point in the history
  • Loading branch information
luoling8192 committed Mar 4, 2025
1 parent 446b830 commit 8457164
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 157 deletions.
2 changes: 1 addition & 1 deletion services/twitter-services/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ let configInstance: ConfigManager | null = null
/**
* Create default configuration manager (singleton)
*/
export function createDefaultConfig(): ConfigManager {
export function useConfigManager(): ConfigManager {
if (configInstance) {
return configInstance
}
Expand Down
18 changes: 9 additions & 9 deletions services/twitter-services/src/core/auth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class TwitterAuthService {
*/
async checkLoginStatus(): Promise<boolean> {
try {
await this.page.goto('https://twitter.com/home')
await this.page.goto('https://x.com/home')
return await this.verifyLogin()
}
catch {
Expand Down Expand Up @@ -259,13 +259,13 @@ export class TwitterAuthService {

try {
// Navigate to a Twitter page
await this.page.goto('https://twitter.com')
await this.page.goto('https://x.com')

// Convert cookies object to array format required by setCookies
const cookieArray = Object.entries(cookies).map(([name, value]) => ({
name,
value,
domain: '.twitter.com',
domain: '.x.com',
path: '/',
}))

Expand All @@ -275,7 +275,7 @@ export class TwitterAuthService {
logger.auth.log(`Set ${cookieArray.length} cookies via browser API`)

// Refresh page to apply cookies
await this.page.goto('https://twitter.com/home')
await this.page.goto('https://x.com/home')

// Verify if login was successful - try multiple times with longer timeout
logger.auth.log('Cookies set, verifying login status...')
Expand All @@ -296,7 +296,7 @@ export class TwitterAuthService {
else if (attempt < verificationAttempts) {
// If not successful but not last attempt, refresh page and wait
logger.auth.log('Refreshing page and trying again...')
await this.page.goto('https://twitter.com/home')
await this.page.goto('https://x.com/home')
await new Promise(resolve => setTimeout(resolve, 3000))
}
}
Expand Down Expand Up @@ -365,7 +365,7 @@ export class TwitterAuthService {

try {
// Navigate to login page
await this.page.goto('https://twitter.com/login')
await this.page.goto('https://x.com/login')

// Wait for login form to appear and enter credentials
try {
Expand Down Expand Up @@ -431,7 +431,7 @@ export class TwitterAuthService {
logger.auth.log('Attempting to navigate to home page and verify login status')

// URL changed - try navigating to home to verify
await this.page.goto('https://twitter.com/home')
await this.page.goto('https://x.com/home')

// Check if login was successful
const isLoggedIn = await this.verifyLogin()
Expand Down Expand Up @@ -517,7 +517,7 @@ export class TwitterAuthService {
const cookieArray = Object.entries(cookies).map(([name, value]) => ({
name,
value, // This will be a string now
domain: '.twitter.com',
domain: '.x.com',
path: '/',
expires: -1, // Session cookie
}))
Expand Down Expand Up @@ -574,7 +574,7 @@ export class TwitterAuthService {
}

// Navigate to home to verify login
await this.page.goto('https://twitter.com/home')
await this.page.goto('https://x.com/home')

// Verify if login was successful
const loginSuccess = await this.verifyLogin()
Expand Down
2 changes: 1 addition & 1 deletion services/twitter-services/src/core/timeline-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class TwitterTimelineService {
async getTimeline(options: TimelineOptions = {}): Promise<Tweet[]> {
try {
// Navigate to home page
await this.page.goto('https://twitter.com/home')
await this.page.goto('https://x.com/home')

// Wait for timeline to load
await this.page.waitForSelector(SELECTORS.TIMELINE.TWEET, { timeout: 10000 })
Expand Down
Loading

0 comments on commit 8457164

Please sign in to comment.