Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/hooks/useRetrieveBskyUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const getServiceType = (messageName: MessageName): ServiceType => {
MESSAGE_NAMES.SEARCH_BSKY_USER_ON_FOLLOW_PAGE,
MESSAGE_NAMES.SEARCH_BSKY_USER_ON_LIST_MEMBERS_PAGE,
MESSAGE_NAMES.SEARCH_BSKY_USER_ON_BLOCK_PAGE,
MESSAGE_NAMES.SEARCH_BSKY_USER_ON_REPOST_PAGE,
),
() => SERVICE_TYPE.X,
)
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const useSearch = () => {
const retrySearch = async () => {
clearErrorMessage();
setIsLoading(true);
await new Promise((r) => setTimeout(r, 3000));
await new Promise((r) => setTimeout(r, 5000));
await searchBskyUser();
};

Expand Down Expand Up @@ -98,6 +98,10 @@ export const useSearch = () => {
P.when((url) => TARGET_URLS_REGEX.FACEBOOK.test(url)),
() => MESSAGE_NAMES.SEARCH_BSKY_USER_ON_FACEBOOK_PAGE,
)
.with(
P.when((url) => TARGET_URLS_REGEX.REPOST.test(url)),
() => MESSAGE_NAMES.SEARCH_BSKY_USER_ON_REPOST_PAGE,
)
.run();

await setToChromeStorage(STORAGE_KEYS.BSKY_MESSAGE_NAME, messageName);
Expand Down
3 changes: 3 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const MESSAGE_NAMES = {
SEARCH_BSKY_USER_ON_INSTAGRAM_PAGE: "search_bsky_user_on_instagram_page",
SEARCH_BSKY_USER_ON_TIKTOK_PAGE: "search_bsky_user_on_tiktok_page",
SEARCH_BSKY_USER_ON_FACEBOOK_PAGE: "search_bsky_user_on_facebook_page",
SEARCH_BSKY_USER_ON_REPOST_PAGE: "search_bsky_user_on_repost_page",
} as const;

export const ACTION_MODE = {
Expand All @@ -24,6 +25,7 @@ export const MESSAGE_NAME_TO_ACTION_MODE_MAP = {
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_INSTAGRAM_PAGE]: ACTION_MODE.FOLLOW,
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_TIKTOK_PAGE]: ACTION_MODE.FOLLOW,
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_FACEBOOK_PAGE]: ACTION_MODE.FOLLOW,
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_REPOST_PAGE]: ACTION_MODE.FOLLOW,
};

const STORAGE_PREFIX = "sky_follower_bridge_storage";
Expand All @@ -46,6 +48,7 @@ export const TARGET_URLS_REGEX = {
INSTAGRAM: /^https:\/\/www\.instagram\.com\/[^/]+\/(followers|following)\/?/,
TIKTOK: /^https:\/\/www\.tiktok\.com/,
FACEBOOK: /^https:\/\/www\.facebook\.com\/friends\/list/,
REPOST: /^https:\/\/(twitter|x)\.com\/[^/]+\/with_replies/,
} as const;

export const MESSAGE_TYPE = {
Expand Down
10 changes: 8 additions & 2 deletions src/services/xService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const USER_CELL_SELECTOR_MAP = {
'[data-testid="primaryColumn"] [data-testid="UserCell"]',
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_LIST_MEMBERS_PAGE]:
'[data-testid="cellInnerDiv"] [data-testid="UserCell"]',
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_BLOCK_PAGE]: '[data-testid="UserCell"]',
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_BLOCK_PAGE]:
'[data-testid="UserCell"]',
[MESSAGE_NAMES.SEARCH_BSKY_USER_ON_REPOST_PAGE]:
'[data-testid="tweet"]:has([data-testid="socialContext"])',
};
const LIST_PAGE_SCROLL_TARGET_SELECTOR = 'div[data-viewportview="true"]';

Expand Down Expand Up @@ -54,7 +57,10 @@ export class XService implements IService {
}

extractUserData(userCell: Element): CrawledUserInfo {
const anchors = Array.from(userCell.querySelectorAll("a"));
const userNameEl = userCell.querySelector('[data-testid="User-Name"]');
const anchors = userNameEl
? Array.from(userNameEl.querySelectorAll("a"))
: Array.from(userCell.querySelectorAll("a"));
const [avatarEl, displayNameEl] = anchors;
const accountName = avatarEl?.getAttribute("href")?.replace("/", "") ?? "";
const accountNameRemoveUnderscore = accountName.replaceAll("_", ""); // bsky does not allow underscores in handle, so remove them.
Expand Down
Loading