mirror of
https://github.com/Dasemu/X-GeoBlock.git
synced 2026-11-26 15:26:09 +00:00
fix: complete rendered profile lookups
This commit is contained in:
1 parent
c31dfa14db
commit
276c0fc8b1
3 files changed
+49
-9
No files matched your search
+24
-1
@@ -110,6 +110,8 @@ async function processArticle(article) {
|
||||
}
|
||||
|
||||
function getFollowingHint(article, username) {
|
||||
const profileHint = getProfileFollowingHint(username);
|
||||
if (profileHint !== null) return Promise.resolve(profileHint);
|
||||
return new Promise((resolve) => {
|
||||
let settled = false;
|
||||
const finish = () => {
|
||||
@@ -126,6 +128,19 @@ function getFollowingHint(article, username) {
|
||||
});
|
||||
}
|
||||
|
||||
function getProfileFollowingHint(username) {
|
||||
const profile = location.pathname.match(/^\/([A-Za-z0-9_]{1,15})(?:\/|$)/)?.[1];
|
||||
if (!profile || profile.toLowerCase() !== username.toLowerCase()) return null;
|
||||
const column = document.querySelector('[data-testid="primaryColumn"]') || document;
|
||||
if (column.querySelector('[data-testid$="-unfollow"]')) return true;
|
||||
if (column.querySelector('[data-testid$="-follow"]')) return false;
|
||||
const buttons = Array.from(column.querySelectorAll("button, [role=button]"));
|
||||
const labels = buttons.slice(0, 30).map((button) => `${button.textContent || ""} ${button.getAttribute("aria-label") || ""}`.trim().toLowerCase());
|
||||
if (labels.some((label) => /^(following|siguiendo|abonné|abonniert|seguindo|seguiti)(\s|$)/.test(label))) return true;
|
||||
if (labels.some((label) => /^(follow|seguir|s’abonner|folgen|seguir)(\s|$)/.test(label))) return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
function getTweetIdentity(article) {
|
||||
const links = article.querySelectorAll('a[href*="/status/"]');
|
||||
for (const link of links) {
|
||||
@@ -176,7 +191,15 @@ function inspectAboutFrame(frame, username) {
|
||||
const timer = setInterval(() => {
|
||||
if (!frame.isConnected) return clearInterval(timer);
|
||||
try {
|
||||
const result = XGeoParser.parseAboutDocument(frame.contentDocument, username);
|
||||
const frameDocument = frame.contentDocument;
|
||||
if (!frameDocument?.documentElement) {
|
||||
if (Date.now() - startedAt > 24000) {
|
||||
clearInterval(timer);
|
||||
debug("Hidden About frame document remained unavailable", { username });
|
||||
}
|
||||
return;
|
||||
}
|
||||
const result = XGeoParser.parseAboutDocument(frameDocument, username);
|
||||
if (result.country) {
|
||||
clearInterval(timer);
|
||||
debug("Hidden About frame parsed", { username, country: result.country, following: result.following });
|
||||
|
||||
Reference in new issue
Block a user