mirror of
https://github.com/snachodog/tok-to-insta-follower-bridge.git
synced 2025-04-10 14:11:22 -06:00
Merge pull request #109 from kawamataryo/filter-impersonation-user
fix: skip searching users with the "impersonation" label.
This commit is contained in:
commit
659fb86ef4
@ -100,4 +100,9 @@ export const DOCUMENT_LINK = {
|
|||||||
"https://www.sky-follower-bridge.dev/troubleshooting.html#page-errors",
|
"https://www.sky-follower-bridge.dev/troubleshooting.html#page-errors",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const BSKY_DOMAIN = process.env.PLASMO_PUBLIC_BSKY_DOMAIN || "bsky.social";
|
export const BSKY_DOMAIN =
|
||||||
|
process.env.PLASMO_PUBLIC_BSKY_DOMAIN || "bsky.social";
|
||||||
|
|
||||||
|
export const BSKY_PROFILE_LABEL = {
|
||||||
|
IMPERSONATION: "impersonation",
|
||||||
|
} as const;
|
||||||
|
@ -29,7 +29,9 @@ export const getAccountNameAndDisplayName = (userCell: Element) => {
|
|||||||
const twAccountNameReplaceUnderscore = twAccountName.replaceAll("_", "-");
|
const twAccountNameReplaceUnderscore = twAccountName.replaceAll("_", "-");
|
||||||
const twDisplayName = displayNameEl?.textContent;
|
const twDisplayName = displayNameEl?.textContent;
|
||||||
const bskyHandle =
|
const bskyHandle =
|
||||||
userCell.textContent?.match(new RegExp(`([^/\\s]+\\.${BSKY_DOMAIN})`))?.[1] ??
|
userCell.textContent?.match(
|
||||||
|
new RegExp(`([^/\\s]+\\.${BSKY_DOMAIN})`),
|
||||||
|
)?.[1] ??
|
||||||
userCell.textContent
|
userCell.textContent
|
||||||
?.match(/bsky\.app\/profile\/([^/\s]+)…?/)?.[1]
|
?.match(/bsky\.app\/profile\/([^/\s]+)…?/)?.[1]
|
||||||
?.replace("…", "") ??
|
?.replace("…", "") ??
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
|
import type { ProfileView } from "@atproto/api/dist/client/types/app/bsky/actor/defs";
|
||||||
import { isSimilarUser } from "~lib/bskyHelpers";
|
import { isSimilarUser } from "~lib/bskyHelpers";
|
||||||
import type { getAccountNameAndDisplayName } from "~lib/domHelpers";
|
import type { getAccountNameAndDisplayName } from "~lib/domHelpers";
|
||||||
import { isOneSymbol } from "~lib/utils";
|
import { isOneSymbol } from "~lib/utils";
|
||||||
import type { BskyServiceWorkerClient } from "./bskyServiceWorkerClient";
|
import type { BskyServiceWorkerClient } from "./bskyServiceWorkerClient";
|
||||||
|
import { BSKY_PROFILE_LABEL } from "./constants";
|
||||||
|
|
||||||
|
const isImpersonationUser = (user: ProfileView) => {
|
||||||
|
return user.labels.some(
|
||||||
|
(label) => label.val === BSKY_PROFILE_LABEL.IMPERSONATION,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const searchBskyUser = async ({
|
export const searchBskyUser = async ({
|
||||||
client,
|
client,
|
||||||
@ -25,11 +33,16 @@ export const searchBskyUser = async ({
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const searchResults = await client.searchUser({
|
const searchResults = await client.searchUser({
|
||||||
term: term,
|
term,
|
||||||
limit: 3,
|
limit: 3,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const searchResult of searchResults) {
|
for (const searchResult of searchResults) {
|
||||||
|
// skip impersonation users
|
||||||
|
if (isImpersonationUser(searchResult)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const { isSimilar: isUserFound, type } = isSimilarUser(
|
const { isSimilar: isUserFound, type } = isSimilarUser(
|
||||||
// TODO: simplify
|
// TODO: simplify
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import { sendToBackground, sendToContentScript } from "@plasmohq/messaging";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
AUTH_FACTOR_TOKEN_REQUIRED_ERROR_MESSAGE,
|
AUTH_FACTOR_TOKEN_REQUIRED_ERROR_MESSAGE,
|
||||||
|
BSKY_DOMAIN,
|
||||||
DOCUMENT_LINK,
|
DOCUMENT_LINK,
|
||||||
MAX_RELOAD_COUNT,
|
MAX_RELOAD_COUNT,
|
||||||
MESSAGE_NAMES,
|
MESSAGE_NAMES,
|
||||||
@ -14,7 +15,6 @@ import {
|
|||||||
RATE_LIMIT_ERROR_MESSAGE,
|
RATE_LIMIT_ERROR_MESSAGE,
|
||||||
STORAGE_KEYS,
|
STORAGE_KEYS,
|
||||||
TARGET_URLS_REGEX,
|
TARGET_URLS_REGEX,
|
||||||
BSKY_DOMAIN,
|
|
||||||
} from "~lib/constants";
|
} from "~lib/constants";
|
||||||
|
|
||||||
function IndexPopup() {
|
function IndexPopup() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user