mirror of
https://github.com/snachodog/tok-to-insta-follower-bridge.git
synced 2025-09-12 23:23:31 -06:00
support for self hosted PDS
This commit is contained in:
@@ -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("…", "") ??
|
||||
|
Reference in New Issue
Block a user