Skip to content

Commit

Permalink
fix: bug that does not work for a while after loading the page (#10)
Browse files Browse the repository at this point in the history
* fix: bug that does not work for a while after loading the page

* fix: linter errors
  • Loading branch information
Robot-Inventor authored Apr 15, 2024
1 parent 2cffd0a commit 6e56786
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ts/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Timeline, Tweet } from "twi-ext";
import { asyncQuerySelector } from "async-query";
import { asyncQuerySelector, asyncQuerySelectorAll } from "async-query";

interface LinkCardProps {
children: {
Expand All @@ -19,8 +19,12 @@ const getReactProps = (element: HTMLElement): LinkCardProps | null => {
return reactPropsName.length ? (element[reactPropsName[0]] as unknown as LinkCardProps) : null;
};

const onNewTweet = (tweet: Tweet): void => {
const linkCards = [...tweet.element.querySelectorAll<HTMLElement>(`[data-testid='card.layoutLarge.media']`)];
// eslint-disable-next-line max-lines-per-function
const onNewTweet = async (tweet: Tweet): Promise<void> => {
const linkCards = [
// eslint-disable-next-line no-extra-parens
...(await asyncQuerySelectorAll<HTMLElement>(`[data-testid='card.layoutLarge.media']`, tweet.element))
];

for (const linkCard of linkCards) {
const reactProps = getReactProps(linkCard);
Expand Down

0 comments on commit 6e56786

Please sign in to comment.