@the-convocation/twitter-scraper 0.17.0 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -324,12 +324,7 @@ class TwitterGuestAuth {
324
324
  headers.set("cookie", await this.getCookieString());
325
325
  }
326
326
  async getCookies() {
327
- const cookies = await Promise.all([
328
- this.jar.getCookies(this.getCookieJarUrl()),
329
- this.jar.getCookies("https://twitter.com"),
330
- this.jar.getCookies("https://x.com")
331
- ]);
332
- return cookies.flat();
327
+ return this.jar.getCookies(this.getCookieJarUrl());
333
328
  }
334
329
  async getCookieString() {
335
330
  const cookies = await this.getCookies();
@@ -347,7 +342,7 @@ class TwitterGuestAuth {
347
342
  }
348
343
  }
349
344
  getCookieJarUrl() {
350
- return typeof document !== "undefined" ? document.location.toString() : "https://twitter.com";
345
+ return typeof document !== "undefined" ? document.location.toString() : "https://x.com";
351
346
  }
352
347
  /**
353
348
  * Updates the authentication state with a new guest token from the Twitter API.
@@ -874,7 +869,7 @@ function parseProfile(legacy, isBlueVerified) {
874
869
  name: legacy.name,
875
870
  pinnedTweetIds: legacy.pinned_tweet_ids_str,
876
871
  tweetsCount: legacy.statuses_count,
877
- url: `https://twitter.com/${legacy.screen_name}`,
872
+ url: `https://x.com/${legacy.screen_name}`,
878
873
  userId: legacy.id_str,
879
874
  username: legacy.screen_name,
880
875
  isBlueVerified: isBlueVerified ?? false,
@@ -1037,7 +1032,7 @@ function parseMediaGroups(media) {
1037
1032
  url: m.media_url_https,
1038
1033
  alt_text: m.ext_alt_text
1039
1034
  });
1040
- } else if (m.type === "video") {
1035
+ } else if (m.type === "video" || m.type === "animated_gif") {
1041
1036
  videos.push(parseVideo(m));
1042
1037
  }
1043
1038
  const sensitive = m.ext_sensitive_media_warning;
@@ -1092,22 +1087,19 @@ function reconstructTweetHtml(tweet, photos, videos) {
1092
1087
  return html;
1093
1088
  }
1094
1089
  function linkHashtagHtml(hashtag) {
1095
- return `<a href="https://twitter.com/hashtag/${hashtag.replace(
1090
+ return `<a href="https://x.com/hashtag/${hashtag.replace(
1096
1091
  "#",
1097
1092
  ""
1098
1093
  )}">${hashtag}</a>`;
1099
1094
  }
1100
1095
  function linkCashtagHtml(cashtag) {
1101
- return `<a href="https://twitter.com/search?q=%24${cashtag.replace(
1096
+ return `<a href="https://x.com/search?q=%24${cashtag.replace(
1102
1097
  "$",
1103
1098
  ""
1104
1099
  )}">${cashtag}</a>`;
1105
1100
  }
1106
1101
  function linkUsernameHtml(username) {
1107
- return `<a href="https://twitter.com/${username.replace(
1108
- "@",
1109
- ""
1110
- )}">${username}</a>`;
1102
+ return `<a href="https://x.com/${username.replace("@", "")}">${username}</a>`;
1111
1103
  }
1112
1104
  function unwrapTcoUrlHtml(tweet, foundedMedia) {
1113
1105
  return function(tco) {
@@ -1176,7 +1168,7 @@ function parseLegacyTweet(coreUser, user, tweet, editControl) {
1176
1168
  name: mention.name
1177
1169
  })),
1178
1170
  name,
1179
- permanentUrl: `https://twitter.com/${username}/status/${tweetId}`,
1171
+ permanentUrl: `https://x.com/${username}/status/${tweetId}`,
1180
1172
  photos,
1181
1173
  replies: tweet.reply_count,
1182
1174
  retweets: tweet.retweet_count,
@@ -1556,7 +1548,7 @@ async function getSearchTimeline(query, maxItems, searchMode, auth, cursor) {
1556
1548
  params.set("fieldToggles", stringify(fieldToggles));
1557
1549
  params.set("variables", stringify(variables));
1558
1550
  const res = await requestApi(
1559
- `https://api.twitter.com/graphql/gkjsKepM6gl_HmFWoWKfgg/SearchTimeline?${params.toString()}`,
1551
+ `https://api.x.com/graphql/gkjsKepM6gl_HmFWoWKfgg/SearchTimeline?${params.toString()}`,
1560
1552
  auth
1561
1553
  );
1562
1554
  if (!res.success) {
@@ -1671,7 +1663,7 @@ async function getFollowingTimeline(userId, maxItems, auth, cursor) {
1671
1663
  params.set("features", stringify(features));
1672
1664
  params.set("variables", stringify(variables));
1673
1665
  const res = await requestApi(
1674
- `https://twitter.com/i/api/graphql/iSicc7LrzWGBgDPL0tM_TQ/Following?${params.toString()}`,
1666
+ `https://x.com/i/api/graphql/iSicc7LrzWGBgDPL0tM_TQ/Following?${params.toString()}`,
1675
1667
  auth
1676
1668
  );
1677
1669
  if (!res.success) {
@@ -1706,7 +1698,7 @@ async function getFollowersTimeline(userId, maxItems, auth, cursor) {
1706
1698
  params.set("features", stringify(features));
1707
1699
  params.set("variables", stringify(variables));
1708
1700
  const res = await requestApi(
1709
- `https://twitter.com/i/api/graphql/rRXFSG5vR6drKr5M37YOTw/Followers?${params.toString()}`,
1701
+ `https://x.com/i/api/graphql/rRXFSG5vR6drKr5M37YOTw/Followers?${params.toString()}`,
1710
1702
  auth
1711
1703
  );
1712
1704
  if (!res.success) {
@@ -1723,7 +1715,7 @@ async function getTrends(auth) {
1723
1715
  params.set("include_page_configuration", "false");
1724
1716
  params.set("entity_tokens", "false");
1725
1717
  const res = await requestApi(
1726
- `https://api.twitter.com/2/guide.json?${params.toString()}`,
1718
+ `https://api.x.com/2/guide.json?${params.toString()}`,
1727
1719
  auth
1728
1720
  );
1729
1721
  if (!res.success) {