diff --git a/src/content.ts b/src/content.ts index 85f1c20..d519604 100644 --- a/src/content.ts +++ b/src/content.ts @@ -34,6 +34,20 @@ const searchAndShowBskyUsers = async ({ removeQuery: async (arg: string) => await agent.unfollow(arg), }) break + case MESSAGE_NAMES.SEARCH_BSKY_USER_ON_LIST_MEMBERS_PAGE: + await searchAndInsertBskyUsers({ + agent, + btnLabel: { + add: "Follow", + remove: "Unfollow", + progressive: "Following", + }, + statusKey: VIEWER_STATE.FOLLOWING, + userCellQueryParam: '[data-testid="UserCell"]', + addQuery: async (arg: string) => await agent.follow(arg), + removeQuery: async (arg: string) => await agent.unfollow(arg), + }) + break case MESSAGE_NAMES.SEARCH_BSKY_USER_ON_BLOCK_PAGE: // TODO: If already blocked, don't show blocking state. because blocking user can't find. await searchAndInsertBskyUsers({ diff --git a/src/lib/constants.ts b/src/lib/constants.ts index e804178..8c4dbb2 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -1,5 +1,6 @@ export const MESSAGE_NAMES = { SEARCH_BSKY_USER_ON_FOLLOW_PAGE: "search_bsky_user_on_follow_page", + SEARCH_BSKY_USER_ON_LIST_MEMBERS_PAGE: "search_bsky_user_on_list_members_page", SEARCH_BSKY_USER_ON_BLOCK_PAGE: "search_bsky_user_on_block_page", } @@ -11,6 +12,7 @@ export const STORAGE_KEYS = { export const TARGET_URLS_REGEX = { FOLLOW: /^https:\/\/(twitter|x)\.com\/[^/]+\/follow/, + LIST: /^https:\/\/(twitter|x)\.com\/[^/]+\/lists\/[^/]+\/members/, BLOCK: /^https:\/\/(twitter|x)\.com\/settings\/blocked/, } as const diff --git a/src/popup.tsx b/src/popup.tsx index d63c980..34cef8d 100644 --- a/src/popup.tsx +++ b/src/popup.tsx @@ -55,6 +55,10 @@ function IndexPopup() { P.when((url) => TARGET_URLS_REGEX.BLOCK.test(url)), () => MESSAGE_NAMES.SEARCH_BSKY_USER_ON_BLOCK_PAGE ) + .with( + P.when((url) => TARGET_URLS_REGEX.LIST.test(url)), + () => MESSAGE_NAMES.SEARCH_BSKY_USER_ON_LIST_MEMBERS_PAGE + ) .run() setMessage(null)