Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit c78c8f6

Browse files
committed
feat: validate tweet link
1 parent 38cce37 commit c78c8f6

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/content-script/hooks/twitter.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ class TwitterHook {
8282
const note = await startPromise;
8383

8484
setTimeout(() => {
85-
const link = document.querySelector('time')?.parentElement?.getAttribute('href');
86-
note.related_urls = [`https://twitter.com${link}`];
85+
const tweet = document.querySelector('[data-testid="tweet"]');
86+
const link = tweet?.querySelector('time')?.parentElement?.getAttribute('href');
87+
if (link) {
88+
note.related_urls = [`https://twitter.com${link}`];
89+
} else {
90+
this.main.xlog('error', 'Failed to get link for: ', tweet);
91+
}
8792

8893
this.main.xlog('info', 'Trigger auto posting tweet...', note);
8994

0 commit comments

Comments
 (0)