···
return authHeader?.split(" ")[1] || null;
58
+
const getRequestUrl = () => {
59
+
let url: string | null = null;
60
+
if (args[0] instanceof Request) {
63
+
url = args[0].toString();
65
+
return decodeURI(url);
let detail: any = undefined;
if (response.url.includes("/xrpc/com.atproto.repo.applyWrites")) {
···
96
+
requestUrl: getRequestUrl(),
97
+
documentUrl: document.location.href,
} else if (response.url.includes("/xrpc/app.bsky.feed.getPosts")) {
···
el.textContent += ` [f: ${s}]`;
el.setAttribute("data-fronter", s);
121
-
const applyFrontersToPage = (fronters: Map<string, any>) => {
132
+
const applyFrontersToPage = (
133
+
fronters: Map<string, any>,
134
+
pageChange: boolean,
// console.log("applyFrontersToPage", fronters);
const match = parseSocialAppPostUrl(document.URL);
124
-
// console.log(match, fronters);
125
-
for (const el of document.querySelectorAll("[data-fronter]")) {
126
-
const previousFronter = el.getAttribute("data-fronter")!;
127
-
// remove fronter text
128
-
el.textContent = el.textContent.replace(` [f: ${previousFronter}]`, "");
129
-
el.removeAttribute("data-fronter");
138
+
console.log("applyFrontersToPage", match, fronters);
141
+
"page change so clearing all elements with data-fronter attribute",
143
+
for (const el of document.querySelectorAll("[data-fronter]")) {
144
+
const previousFronter = el.getAttribute("data-fronter")!;
145
+
// remove fronter text
146
+
el.textContent = el.textContent.replace(
147
+
` [f: ${previousFronter}]`,
150
+
el.removeAttribute("data-fronter");
if (fronters.size === 0) return;
for (const el of document.getElementsByTagName("a")) {
···
const fronter = fronters.get(path);
if (!fronter || fronter.members.length === 0) continue;
const isFocusedPost = fronter.depth === 0;
137
-
if (isFocusedPost && match && match.rkey !== fronter.rkey) continue;
138
-
if (isFocusedPost && el.ariaLabel !== fronter.displayName) continue;
159
+
if (isFocusedPost) if (match && match.rkey !== fronter.rkey) continue;
160
+
if (isFocusedPost) if (el.ariaLabel !== fronter.displayName) continue;
const displayNameElement = isFocusedPost
? (el.firstElementChild?.firstElementChild?.firstElementChild
?.firstElementChild?.firstElementChild ?? null)
: (el.parentElement?.firstElementChild?.firstElementChild
?.firstElementChild?.firstElementChild ?? null);
if (!displayNameElement) continue;
145
-
// console.log(path, fronter, displayNameElement);
applyFronterName(displayNameElement, fronter.members);
···
165
-
// console.log("applying cached fronters");
166
-
applyFrontersToPage(updated);
186
+
console.log("applying cached fronters", updated);
187
+
applyFrontersToPage(updated, true);
// check if we are on profile so we can update fronters if the post tab is clicked on
const postTabElement = document.querySelector(
···
window.addEventListener("message", (event) => {
if (!["TIMELINE_FRONTER", "THREAD_FRONTER"].includes(event.data.type))
185
-
applyFrontersToPage(event.data.results as Map<string, any>);
206
+
console.log(`received ${event.data.type} fronters`, event.data.results);
207
+
applyFrontersToPage(event.data.results, false);