Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AccountCollector Selector, add build and start commands for Windows #195

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

maozdemir
Copy link

@maozdemir maozdemir commented Aug 14, 2023

Fixed the userCells selector that was previously failing on gathering users.
Using a placeholder number for totalUserCount due to the unavailability of the API.
Introduced new commands for starting and building the application on Windows platforms.

@maozdemir
Copy link
Author

maozdemir commented Aug 14, 2023

Theorically the function below should work, but couldn't get it working...

	private async getTotalUsersCount(): Promise<number> {
		const isRetweetsPage = await TwitterPage.isRetweetsPage();
		const isTweetPage = await TwitterPage.isTweetPage();
		const isListPage = await TwitterPage.isListPage();
		let totalUsersCount = -1;
		if (isTweetPage) {
			const interactionElements = document.querySelectorAll('article div[role="group"] a span');
			let tweetLikes = -1;
			let tweetReposts = -1;
			interactionElements.forEach(iElement => {
				if (iElement.textContent === 'Likes') {
					tweetLikes = parseInt(iElement.parentElement.parentElement.querySelector('[data-testid="app-text-transition-container"]').textContent);
				} else if (iElement.textContent === 'Reposts') {
					tweetReposts = parseInt(iElement.parentElement.parentElement.querySelector('[data-testid="app-text-transition-container"]').textContent);
				}
			});
			totalUsersCount = isRetweetsPage ? tweetReposts : tweetLikes;
		} else if (isListPage) {
			const listId = await TwitterPage.getListId();
			const list = await APIService.getList(listId);
			totalUsersCount =
				isListPage === AccountList.followers ? list.subscriber_count : list.member_count;
		}
		// prevent multiple api calls of not successful:
		if (!totalUsersCount) {
			totalUsersCount = -1;
		}

		return totalUsersCount;
	}

@pkreissel pkreissel requested a review from dmstern September 20, 2023 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant