mirror of
https://github.com/snachodog/tok-to-insta-follower-bridge.git
synced 2025-09-13 07:23:32 -06:00
@@ -1,4 +1,5 @@
|
||||
import { AtUri, AtpAgent, type AtpSessionData } from "@atproto/api";
|
||||
import { BSKY_DOMAIN } from "./constants";
|
||||
|
||||
// try and cut down the amount of session resumes by caching the clients
|
||||
const clientCache = new Map<string, BskyClient>();
|
||||
@@ -10,7 +11,7 @@ export type BskyLoginParams = {
|
||||
};
|
||||
|
||||
export class BskyClient {
|
||||
private service = "https://bsky.social";
|
||||
private service = `https://${BSKY_DOMAIN}`;
|
||||
me: {
|
||||
did: string;
|
||||
handle: string;
|
||||
|
@@ -99,3 +99,5 @@ export const DOCUMENT_LINK = {
|
||||
PAGE_ERROR:
|
||||
"https://www.sky-follower-bridge.dev/troubleshooting.html#page-errors",
|
||||
} as const;
|
||||
|
||||
export const BSKY_DOMAIN = process.env.PLASMO_PUBLIC_BSKY_DOMAIN || "bsky.social";
|
@@ -1,3 +1,5 @@
|
||||
import { BSKY_DOMAIN } from "./constants";
|
||||
|
||||
export const getUserCells = ({
|
||||
queryParam,
|
||||
filterInsertedElement,
|
||||
@@ -20,13 +22,14 @@ export const getUserCells = ({
|
||||
};
|
||||
|
||||
export const getAccountNameAndDisplayName = (userCell: Element) => {
|
||||
const [avatarEl, displayNameEl] = userCell.querySelectorAll("a");
|
||||
const anchors = Array.from(userCell.querySelectorAll("a"));
|
||||
const [avatarEl, displayNameEl] = anchors;
|
||||
const twAccountName = avatarEl?.getAttribute("href")?.replace("/", "");
|
||||
const twAccountNameRemoveUnderscore = twAccountName.replaceAll("_", ""); // bsky does not allow underscores in handle, so remove them.
|
||||
const twAccountNameReplaceUnderscore = twAccountName.replaceAll("_", "-");
|
||||
const twDisplayName = displayNameEl?.textContent;
|
||||
const bskyHandle =
|
||||
userCell.textContent?.match(/([^/\s]+\.bsky\.social)/)?.[1] ??
|
||||
userCell.textContent?.match(new RegExp(`([^/\\s]+\\.${BSKY_DOMAIN})`))?.[1] ??
|
||||
userCell.textContent
|
||||
?.match(/bsky\.app\/profile\/([^/\s]+)…?/)?.[1]
|
||||
?.replace("…", "") ??
|
||||
|
@@ -14,6 +14,7 @@ import {
|
||||
RATE_LIMIT_ERROR_MESSAGE,
|
||||
STORAGE_KEYS,
|
||||
TARGET_URLS_REGEX,
|
||||
BSKY_DOMAIN,
|
||||
} from "~lib/constants";
|
||||
|
||||
function IndexPopup() {
|
||||
@@ -135,7 +136,7 @@ function IndexPopup() {
|
||||
setIsLoading(true);
|
||||
|
||||
const formattedIdentifier = (
|
||||
identifier.includes(".") ? identifier : `${identifier}.bsky.social`
|
||||
identifier.includes(".") ? identifier : `${identifier}.${BSKY_DOMAIN}`
|
||||
).replace(/^@/, "");
|
||||
try {
|
||||
const { session, error } = await sendToBackground({
|
||||
@@ -236,7 +237,7 @@ function IndexPopup() {
|
||||
<input
|
||||
type="text"
|
||||
name="identifier"
|
||||
placeholder="your-username.bsky.social"
|
||||
placeholder={`your-username.${BSKY_DOMAIN}`}
|
||||
value={identifier}
|
||||
onChange={(e) => setIdentifier(e.target.value)}
|
||||
className="input input-bordered input-sm w-full max-w-xs join-item focus:outline-none mt-1"
|
||||
|
Reference in New Issue
Block a user