gs-x-parser 1.0.3 → 1.0.5
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.
- package/lib/type.cjs +1 -1
- package/lib/type.d.ts +2 -6
- package/lib/type.mjs +1 -1
- package/package.json +2 -2
- package/lib/listen-tweet-start.cjs +0 -68
- package/lib/listen-tweet-start.d.ts +0 -9
- package/lib/listen-tweet-start.mjs +0 -74
package/lib/type.cjs
CHANGED
|
@@ -6,5 +6,5 @@ const DomDisplayTypes = [
|
|
|
6
6
|
"MediaGrid",
|
|
7
7
|
"User"
|
|
8
8
|
], USER_TYPENAMES = ["User", "UserUnavailable"], TWEET_TYPENAMES = ["Tweet", "TextTombstone", "TweetTombstone", "TweetWithVisibilityResults", "ContextualTweetInterstitial"], COMMUNITY_TYPENAMES = ["Community", "CommunityDeleteActionUnavailable", "CommunityUserDefaultModerationState", "CommunityJoinRequestsUnavailable"], TIMELINE_TYPENAMES = ["TimelineTimelineItem", "TimelineMessagePrompt"], TIMELINE_ITEM_TYPENAMES = ["TimelineTweet", "TimelineMessagePrompt"], TIMELINE_INSTRUCTION_TYPES = ["TimelineAddEntries"], TIMELINE_ENTRY_TYPES = ["TimelineTimelineItem", "TimelineTimelineModule", "TimelineTimelineCursor"], TIMELINE_ITEM_TYPES = ["TimelineTweet", "TimelineMessagePrompt"], MEDIA_TYPES = ["photo", "video", "animated_gif"], ELIGIBILITY_TYPES = ["Eligible", "IneligibleUserUnauthorized"], DISPLAY_TYPES = ["Carousel", "Vertical", "VerticalConversation", "Classic", "EntireTweet"], TWEET_DISPLAY_TYPES = ["CondensedTweet", "Tweet", "SelfThread"], USER_DISPLAY_TYPES = ["SubscribableUser", "User"], INJECTION_TYPES = ["ForYouInNetwork", "ForYouPromoted", "WhoToFollow", "creators-only-connect-tab", "CommunityToJoin", "FollowingInNetwork"], TRANSPARENT_GUIDE_DETAIL_TYPES = ["TimelineEventUrtMetadata"], ELEMENT_TYPES = ["tweet", "user", "event", "feedback", "trend", "users_followed_you", "generic_report_received", "users_liked_your_tweet", "user_quoted_your_tweet", "user_replied_to_your_tweet", "users_retweeted_your_tweet", "user_mentioned_you"], TWEET_QUALITIES = ["HighQuality", "LowQuality", "AbusiveQuality", "RelatedTweet"], COMPONENT_VALUES = ["url", "tweet", "trends", "unified_events", "related_tweet", "suggest_who_to_follow", "for_you_in_network", "for-you-promoted", "alt-text-prompt-injection", "ads-sharing-x-premium-upsell-candidate"], ITEM_TYPES = ["TimelineTweet", "TimelineUser", "TimelineEventSummary", "TimelineMessagePrompt", "TimelineCommunity", "CommunityPinnedTimeline"], CURSOR_TYPES = ["Top", "Bottom", "ShowMore", "ShowMoreThreads"], INSTRUCTION_TYPES = ["TimelineClearCache", "TimelineAddEntries", "TimelineTerminateTimeline", "TimelineShowAlert", "TimelineShowCover"], CONTENT_TYPES = ["TimelineTweetMedia", "TimelineUrl"], VIDEO_CONTENT_TYPES = ["application/x-mpegURL", "video/mp4"], VIDEO_QUALITIES = ["high", "medium", "low"], MESSAGE_INBOX_TIMELINE_INDEXES = ["trusted", "untrusted", "untrusted_low_quality"], NOTIFICATION_KEYS = ["clearCache", "addEntries", "clearEntriesUnreadState", "markEntriesUnreadGreaterThanSortIndex"], VERIFIED_TYPES = ["Business", "Government", "Blue", "None"], USER_LABEL_TYPES = ["BusinessLabel", "AutomatedLabel"], URL_TYPES = ["ExternalUrl", "DeepLink", "UrtEndpoint"], VIEW_STATES = ["EnabledWithCount", "Enabled"], LEGACY_CARD_BINDING_KEY_TYPES = ["thumbnail_image", "description", "domain", "thumbnail_image_large", "thumbnail_image_original", "thumbnail_image_small", "thumbnail_image_x_large", "thumbnail_image_color", "summary_photo_image", "summary_photo_image_small", "summary_photo_image_large", "summary_photo_image_x_large", "summary_photo_image_original", "summary_photo_image_color", "photo_image_full_size_color", "vanity_url", "title", "card_url", "creator", "site", "player_image", "player_image_small", "player_image_large", "player_image_x_large", "player_image_original", "player_image_color", "player_url", "player_width", "player_height", "app_name", "app_is_free", "app_star_rating", "app_num_ratings", "app_price_currency", "unified_card", "app_price_amount"], LEGACY_CARD_BINDING_VALUE_TYPES = ["STRING", "IMAGE_COLOR", "IMAGE", "USER"];
|
|
9
|
-
var IdPrefixes = /* @__PURE__ */ ((IdPrefixes2) => (IdPrefixes2.MessagePrompt = "messageprompt-", IdPrefixes2.NormalTweet = "tweet-", IdPrefixes2.PromotedTweet = "promoted-tweet-", IdPrefixes2.User = "user-", IdPrefixes2.CommunityToJoin = "community-to-join-", IdPrefixes2.HomeConversation = "home-conversation-", IdPrefixes2.Conversationthread = "conversationthread-", IdPrefixes2.CommunityConversation = "community-conversation-", IdPrefixes2.CommunityGrid = "communities-grid-", IdPrefixes2.PinnedTweets = "pinned-tweets-", IdPrefixes2.WhoToFollow = "who-to-follow-", IdPrefixes2.CreatorsOnlyConnectTab = "creators-only-connect-tab-", IdPrefixes2.Label = "label-", IdPrefixes2.Guide = "Guide-", IdPrefixes2.ProfileGrid = "profile-grid-", IdPrefixes2.Notification = "notification-", IdPrefixes2.Cursor = "cursor-", IdPrefixes2.CursorTop = "cursor-top-", IdPrefixes2.CursorBottom = "cursor-bottom-", IdPrefixes2.TweetDetailRelatedTweets = "tweetdetailrelatedtweets-", IdPrefixes2.Trends = "trends-", IdPrefixes2))(IdPrefixes || {}), ListenTweetEvents = /* @__PURE__ */ ((ListenTweetEvents2) => (ListenTweetEvents2.VideoDetected = "__listen-tweet-video-detected", ListenTweetEvents2.TweetDetected = "__listen-tweet-tweet-detected", ListenTweetEvents2.UserDetected = "__listen-tweet-user-detected", ListenTweetEvents2.TweetRendered = "__listen-tweet-tweet-rendered", ListenTweetEvents2
|
|
9
|
+
var IdPrefixes = /* @__PURE__ */ ((IdPrefixes2) => (IdPrefixes2.MessagePrompt = "messageprompt-", IdPrefixes2.NormalTweet = "tweet-", IdPrefixes2.PromotedTweet = "promoted-tweet-", IdPrefixes2.User = "user-", IdPrefixes2.CommunityToJoin = "community-to-join-", IdPrefixes2.HomeConversation = "home-conversation-", IdPrefixes2.Conversationthread = "conversationthread-", IdPrefixes2.CommunityConversation = "community-conversation-", IdPrefixes2.CommunityGrid = "communities-grid-", IdPrefixes2.PinnedTweets = "pinned-tweets-", IdPrefixes2.WhoToFollow = "who-to-follow-", IdPrefixes2.CreatorsOnlyConnectTab = "creators-only-connect-tab-", IdPrefixes2.Label = "label-", IdPrefixes2.Guide = "Guide-", IdPrefixes2.ProfileGrid = "profile-grid-", IdPrefixes2.Notification = "notification-", IdPrefixes2.Cursor = "cursor-", IdPrefixes2.CursorTop = "cursor-top-", IdPrefixes2.CursorBottom = "cursor-bottom-", IdPrefixes2.TweetDetailRelatedTweets = "tweetdetailrelatedtweets-", IdPrefixes2.Trends = "trends-", IdPrefixes2))(IdPrefixes || {}), ListenTweetEvents = /* @__PURE__ */ ((ListenTweetEvents2) => (ListenTweetEvents2.VideoDetected = "__listen-tweet-video-detected", ListenTweetEvents2.TweetDetected = "__listen-tweet-tweet-detected", ListenTweetEvents2.UserDetected = "__listen-tweet-user-detected", ListenTweetEvents2.TweetRendered = "__listen-tweet-tweet-rendered", ListenTweetEvents2))(ListenTweetEvents || {});
|
|
10
10
|
exports.COMMUNITY_TYPENAMES = COMMUNITY_TYPENAMES, exports.COMPONENT_VALUES = COMPONENT_VALUES, exports.CONTENT_TYPES = CONTENT_TYPES, exports.CURSOR_TYPES = CURSOR_TYPES, exports.DISPLAY_TYPES = DISPLAY_TYPES, exports.DomDisplayTypes = DomDisplayTypes, exports.ELEMENT_TYPES = ELEMENT_TYPES, exports.ELIGIBILITY_TYPES = ELIGIBILITY_TYPES, exports.INJECTION_TYPES = INJECTION_TYPES, exports.INSTRUCTION_TYPES = INSTRUCTION_TYPES, exports.ITEM_TYPES = ITEM_TYPES, exports.IdPrefixes = IdPrefixes, exports.LEGACY_CARD_BINDING_KEY_TYPES = LEGACY_CARD_BINDING_KEY_TYPES, exports.LEGACY_CARD_BINDING_VALUE_TYPES = LEGACY_CARD_BINDING_VALUE_TYPES, exports.ListenTweetEvents = ListenTweetEvents, exports.MEDIA_TYPES = MEDIA_TYPES, exports.MESSAGE_INBOX_TIMELINE_INDEXES = MESSAGE_INBOX_TIMELINE_INDEXES, exports.NOTIFICATION_KEYS = NOTIFICATION_KEYS, exports.TIMELINE_ENTRY_TYPES = TIMELINE_ENTRY_TYPES, exports.TIMELINE_INSTRUCTION_TYPES = TIMELINE_INSTRUCTION_TYPES, exports.TIMELINE_ITEM_TYPENAMES = TIMELINE_ITEM_TYPENAMES, exports.TIMELINE_ITEM_TYPES = TIMELINE_ITEM_TYPES, exports.TIMELINE_TYPENAMES = TIMELINE_TYPENAMES, exports.TRANSPARENT_GUIDE_DETAIL_TYPES = TRANSPARENT_GUIDE_DETAIL_TYPES, exports.TWEET_DISPLAY_TYPES = TWEET_DISPLAY_TYPES, exports.TWEET_QUALITIES = TWEET_QUALITIES, exports.TWEET_TYPENAMES = TWEET_TYPENAMES, exports.URL_TYPES = URL_TYPES, exports.USER_DISPLAY_TYPES = USER_DISPLAY_TYPES, exports.USER_LABEL_TYPES = USER_LABEL_TYPES, exports.USER_TYPENAMES = USER_TYPENAMES, exports.VERIFIED_TYPES = VERIFIED_TYPES, exports.VIDEO_CONTENT_TYPES = VIDEO_CONTENT_TYPES, exports.VIDEO_QUALITIES = VIDEO_QUALITIES, exports.VIEW_STATES = VIEW_STATES;
|
package/lib/type.d.ts
CHANGED
|
@@ -2219,7 +2219,7 @@ interface IListenTweetOption {
|
|
|
2219
2219
|
enableVideoDetected?: boolean;
|
|
2220
2220
|
enableTweetDetected?: boolean;
|
|
2221
2221
|
enableUserDetected?: boolean;
|
|
2222
|
-
|
|
2222
|
+
enableTweetRendered?: boolean;
|
|
2223
2223
|
}
|
|
2224
2224
|
|
|
2225
2225
|
declare const enum ListenTweetEvents {
|
|
@@ -2238,11 +2238,7 @@ declare const enum ListenTweetEvents {
|
|
|
2238
2238
|
/**
|
|
2239
2239
|
* 推文渲染
|
|
2240
2240
|
*/
|
|
2241
|
-
TweetRendered = "__listen-tweet-tweet-rendered"
|
|
2242
|
-
/**
|
|
2243
|
-
* 视频渲染
|
|
2244
|
-
*/
|
|
2245
|
-
VideoRendered = "__listen-tweet-video-rendered"
|
|
2241
|
+
TweetRendered = "__listen-tweet-tweet-rendered"
|
|
2246
2242
|
}
|
|
2247
2243
|
|
|
2248
2244
|
export { COMMUNITY_TYPENAMES, COMPONENT_VALUES, CONTENT_TYPES, CURSOR_TYPES, DISPLAY_TYPES, DomDisplayTypes, ELEMENT_TYPES, ELIGIBILITY_TYPES, INJECTION_TYPES, INSTRUCTION_TYPES, ITEM_TYPES, IdPrefixes, LEGACY_CARD_BINDING_KEY_TYPES, LEGACY_CARD_BINDING_VALUE_TYPES, ListenTweetEvents, MEDIA_TYPES, MESSAGE_INBOX_TIMELINE_INDEXES, NOTIFICATION_KEYS, TIMELINE_ENTRY_TYPES, TIMELINE_INSTRUCTION_TYPES, TIMELINE_ITEM_TYPENAMES, TIMELINE_ITEM_TYPES, TIMELINE_TYPENAMES, TRANSPARENT_GUIDE_DETAIL_TYPES, TWEET_DISPLAY_TYPES, TWEET_QUALITIES, TWEET_TYPENAMES, URL_TYPES, USER_DISPLAY_TYPES, USER_LABEL_TYPES, USER_TYPENAMES, VERIFIED_TYPES, VIDEO_CONTENT_TYPES, VIDEO_QUALITIES, VIEW_STATES };
|
package/lib/type.mjs
CHANGED
|
@@ -5,7 +5,7 @@ const DomDisplayTypes = [
|
|
|
5
5
|
"MediaGrid",
|
|
6
6
|
"User"
|
|
7
7
|
], USER_TYPENAMES = ["User", "UserUnavailable"], TWEET_TYPENAMES = ["Tweet", "TextTombstone", "TweetTombstone", "TweetWithVisibilityResults", "ContextualTweetInterstitial"], COMMUNITY_TYPENAMES = ["Community", "CommunityDeleteActionUnavailable", "CommunityUserDefaultModerationState", "CommunityJoinRequestsUnavailable"], TIMELINE_TYPENAMES = ["TimelineTimelineItem", "TimelineMessagePrompt"], TIMELINE_ITEM_TYPENAMES = ["TimelineTweet", "TimelineMessagePrompt"], TIMELINE_INSTRUCTION_TYPES = ["TimelineAddEntries"], TIMELINE_ENTRY_TYPES = ["TimelineTimelineItem", "TimelineTimelineModule", "TimelineTimelineCursor"], TIMELINE_ITEM_TYPES = ["TimelineTweet", "TimelineMessagePrompt"], MEDIA_TYPES = ["photo", "video", "animated_gif"], ELIGIBILITY_TYPES = ["Eligible", "IneligibleUserUnauthorized"], DISPLAY_TYPES = ["Carousel", "Vertical", "VerticalConversation", "Classic", "EntireTweet"], TWEET_DISPLAY_TYPES = ["CondensedTweet", "Tweet", "SelfThread"], USER_DISPLAY_TYPES = ["SubscribableUser", "User"], INJECTION_TYPES = ["ForYouInNetwork", "ForYouPromoted", "WhoToFollow", "creators-only-connect-tab", "CommunityToJoin", "FollowingInNetwork"], TRANSPARENT_GUIDE_DETAIL_TYPES = ["TimelineEventUrtMetadata"], ELEMENT_TYPES = ["tweet", "user", "event", "feedback", "trend", "users_followed_you", "generic_report_received", "users_liked_your_tweet", "user_quoted_your_tweet", "user_replied_to_your_tweet", "users_retweeted_your_tweet", "user_mentioned_you"], TWEET_QUALITIES = ["HighQuality", "LowQuality", "AbusiveQuality", "RelatedTweet"], COMPONENT_VALUES = ["url", "tweet", "trends", "unified_events", "related_tweet", "suggest_who_to_follow", "for_you_in_network", "for-you-promoted", "alt-text-prompt-injection", "ads-sharing-x-premium-upsell-candidate"], ITEM_TYPES = ["TimelineTweet", "TimelineUser", "TimelineEventSummary", "TimelineMessagePrompt", "TimelineCommunity", "CommunityPinnedTimeline"], CURSOR_TYPES = ["Top", "Bottom", "ShowMore", "ShowMoreThreads"], INSTRUCTION_TYPES = ["TimelineClearCache", "TimelineAddEntries", "TimelineTerminateTimeline", "TimelineShowAlert", "TimelineShowCover"], CONTENT_TYPES = ["TimelineTweetMedia", "TimelineUrl"], VIDEO_CONTENT_TYPES = ["application/x-mpegURL", "video/mp4"], VIDEO_QUALITIES = ["high", "medium", "low"], MESSAGE_INBOX_TIMELINE_INDEXES = ["trusted", "untrusted", "untrusted_low_quality"], NOTIFICATION_KEYS = ["clearCache", "addEntries", "clearEntriesUnreadState", "markEntriesUnreadGreaterThanSortIndex"], VERIFIED_TYPES = ["Business", "Government", "Blue", "None"], USER_LABEL_TYPES = ["BusinessLabel", "AutomatedLabel"], URL_TYPES = ["ExternalUrl", "DeepLink", "UrtEndpoint"], VIEW_STATES = ["EnabledWithCount", "Enabled"], LEGACY_CARD_BINDING_KEY_TYPES = ["thumbnail_image", "description", "domain", "thumbnail_image_large", "thumbnail_image_original", "thumbnail_image_small", "thumbnail_image_x_large", "thumbnail_image_color", "summary_photo_image", "summary_photo_image_small", "summary_photo_image_large", "summary_photo_image_x_large", "summary_photo_image_original", "summary_photo_image_color", "photo_image_full_size_color", "vanity_url", "title", "card_url", "creator", "site", "player_image", "player_image_small", "player_image_large", "player_image_x_large", "player_image_original", "player_image_color", "player_url", "player_width", "player_height", "app_name", "app_is_free", "app_star_rating", "app_num_ratings", "app_price_currency", "unified_card", "app_price_amount"], LEGACY_CARD_BINDING_VALUE_TYPES = ["STRING", "IMAGE_COLOR", "IMAGE", "USER"];
|
|
8
|
-
var IdPrefixes = /* @__PURE__ */ ((IdPrefixes2) => (IdPrefixes2.MessagePrompt = "messageprompt-", IdPrefixes2.NormalTweet = "tweet-", IdPrefixes2.PromotedTweet = "promoted-tweet-", IdPrefixes2.User = "user-", IdPrefixes2.CommunityToJoin = "community-to-join-", IdPrefixes2.HomeConversation = "home-conversation-", IdPrefixes2.Conversationthread = "conversationthread-", IdPrefixes2.CommunityConversation = "community-conversation-", IdPrefixes2.CommunityGrid = "communities-grid-", IdPrefixes2.PinnedTweets = "pinned-tweets-", IdPrefixes2.WhoToFollow = "who-to-follow-", IdPrefixes2.CreatorsOnlyConnectTab = "creators-only-connect-tab-", IdPrefixes2.Label = "label-", IdPrefixes2.Guide = "Guide-", IdPrefixes2.ProfileGrid = "profile-grid-", IdPrefixes2.Notification = "notification-", IdPrefixes2.Cursor = "cursor-", IdPrefixes2.CursorTop = "cursor-top-", IdPrefixes2.CursorBottom = "cursor-bottom-", IdPrefixes2.TweetDetailRelatedTweets = "tweetdetailrelatedtweets-", IdPrefixes2.Trends = "trends-", IdPrefixes2))(IdPrefixes || {}), ListenTweetEvents = /* @__PURE__ */ ((ListenTweetEvents2) => (ListenTweetEvents2.VideoDetected = "__listen-tweet-video-detected", ListenTweetEvents2.TweetDetected = "__listen-tweet-tweet-detected", ListenTweetEvents2.UserDetected = "__listen-tweet-user-detected", ListenTweetEvents2.TweetRendered = "__listen-tweet-tweet-rendered", ListenTweetEvents2
|
|
8
|
+
var IdPrefixes = /* @__PURE__ */ ((IdPrefixes2) => (IdPrefixes2.MessagePrompt = "messageprompt-", IdPrefixes2.NormalTweet = "tweet-", IdPrefixes2.PromotedTweet = "promoted-tweet-", IdPrefixes2.User = "user-", IdPrefixes2.CommunityToJoin = "community-to-join-", IdPrefixes2.HomeConversation = "home-conversation-", IdPrefixes2.Conversationthread = "conversationthread-", IdPrefixes2.CommunityConversation = "community-conversation-", IdPrefixes2.CommunityGrid = "communities-grid-", IdPrefixes2.PinnedTweets = "pinned-tweets-", IdPrefixes2.WhoToFollow = "who-to-follow-", IdPrefixes2.CreatorsOnlyConnectTab = "creators-only-connect-tab-", IdPrefixes2.Label = "label-", IdPrefixes2.Guide = "Guide-", IdPrefixes2.ProfileGrid = "profile-grid-", IdPrefixes2.Notification = "notification-", IdPrefixes2.Cursor = "cursor-", IdPrefixes2.CursorTop = "cursor-top-", IdPrefixes2.CursorBottom = "cursor-bottom-", IdPrefixes2.TweetDetailRelatedTweets = "tweetdetailrelatedtweets-", IdPrefixes2.Trends = "trends-", IdPrefixes2))(IdPrefixes || {}), ListenTweetEvents = /* @__PURE__ */ ((ListenTweetEvents2) => (ListenTweetEvents2.VideoDetected = "__listen-tweet-video-detected", ListenTweetEvents2.TweetDetected = "__listen-tweet-tweet-detected", ListenTweetEvents2.UserDetected = "__listen-tweet-user-detected", ListenTweetEvents2.TweetRendered = "__listen-tweet-tweet-rendered", ListenTweetEvents2))(ListenTweetEvents || {});
|
|
9
9
|
export {
|
|
10
10
|
COMMUNITY_TYPENAMES,
|
|
11
11
|
COMPONENT_VALUES,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gs-x-parser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "grain-sand"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"gs-dom": "
|
|
9
|
+
"gs-dom": "^0.2.6",
|
|
10
10
|
"gs-web-hooks": "^1.0.0"
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://github.com/grain-sand/gs-x-parser",
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var xhr = require('gs-web-hooks/xhr'), parser = require('./parser.cjs'), event = require('gs-dom/event'), type = require('./type.cjs'), frsProbe = require('gs-dom/frs-probe'), observer = require('gs-dom/observer');
|
|
3
|
-
const ListenFlagKey = "__listen-tweet-flag-key";
|
|
4
|
-
class ListenFlag {
|
|
5
|
-
static #flag;
|
|
6
|
-
static get flag() {
|
|
7
|
-
return this.#flag || (this.#flag = self[ListenFlagKey]);
|
|
8
|
-
}
|
|
9
|
-
static isInit(arg) {
|
|
10
|
-
const init = !!this.flag;
|
|
11
|
-
return arg && this.update(arg), init;
|
|
12
|
-
}
|
|
13
|
-
static update(arg) {
|
|
14
|
-
self[ListenFlagKey] ? (arg?.enableTweetDetected && (self[ListenFlagKey].enableTweetDetected = !0), arg?.enableUserDetected && (self[ListenFlagKey].enableUserDetected = !0)) : Object.defineProperty(self, ListenFlagKey, {
|
|
15
|
-
value: { ...arg },
|
|
16
|
-
enumerable: !1,
|
|
17
|
-
configurable: !1,
|
|
18
|
-
writable: !1
|
|
19
|
-
}), this.#flag = self[ListenFlagKey];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const timelineRegex = /TweetDetail|Timeline|Bookmarks|UserTweets|UserMedia|Likes/, id = "__listen-tweet-interceptor";
|
|
23
|
-
function listenNet() {
|
|
24
|
-
xhr.addXhrInterceptor({
|
|
25
|
-
id,
|
|
26
|
-
before: (url) => timelineRegex.test(url) ? url : void 0,
|
|
27
|
-
after: (text) => {
|
|
28
|
-
const json = JSON.parse(text), { tweets, users, videos } = parser.XParser.parseSimple(json);
|
|
29
|
-
if (videos?.length) try {
|
|
30
|
-
event.trigger(type.ListenTweetEvents.VideoDetected, { detail: videos });
|
|
31
|
-
} catch {
|
|
32
|
-
}
|
|
33
|
-
const flag = ListenFlag.flag || {};
|
|
34
|
-
if (flag.enableTweetDetected && tweets?.length) try {
|
|
35
|
-
event.trigger(type.ListenTweetEvents.UserDetected, { detail: tweets });
|
|
36
|
-
} catch {
|
|
37
|
-
}
|
|
38
|
-
if (flag.enableUserDetected && users?.length) try {
|
|
39
|
-
event.trigger(type.ListenTweetEvents.UserDetected, { detail: users });
|
|
40
|
-
} catch {
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const containerSelector = "main,main *", regionSelector = 'main [data-testid="primaryColumn"] [role="region"]', cellSelector = `${regionSelector} [data-testid="cellInnerDiv"]`, itemSelector = `${cellSelector} [role="listitem"]`, tweetSelector = [cellSelector, itemSelector].join(",");
|
|
46
|
-
function addedElements(els) {
|
|
47
|
-
const tweets = [];
|
|
48
|
-
function processTarget(el) {
|
|
49
|
-
if (el.matches(tweetSelector)) {
|
|
50
|
-
const id2 = frsProbe.getTweetId(el);
|
|
51
|
-
id2 && tweets.push(id2);
|
|
52
|
-
} else el.matches(containerSelector) && el.clientHeight > 300 && els.push(...el.querySelectorAll(tweetSelector));
|
|
53
|
-
}
|
|
54
|
-
for (let i = 0; i < els.length; i++)
|
|
55
|
-
try {
|
|
56
|
-
processTarget(els[i]);
|
|
57
|
-
} catch (e) {
|
|
58
|
-
console.warn(e);
|
|
59
|
-
}
|
|
60
|
-
tweets.length && event.trigger(type.ListenTweetEvents.TweetRendered, { detail: tweets });
|
|
61
|
-
}
|
|
62
|
-
function observePage() {
|
|
63
|
-
observer.observe({ subtree: !0, addedElements });
|
|
64
|
-
}
|
|
65
|
-
function startListen(option) {
|
|
66
|
-
ListenFlag.isInit(option) || (listenNet(), observePage());
|
|
67
|
-
}
|
|
68
|
-
exports.startListen = startListen;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { addXhrInterceptor } from 'gs-web-hooks/xhr';
|
|
2
|
-
import { XParser } from './parser.mjs';
|
|
3
|
-
import { trigger } from 'gs-dom/event';
|
|
4
|
-
import { ListenTweetEvents } from './type.mjs';
|
|
5
|
-
import { getTweetId } from 'gs-dom/frs-probe';
|
|
6
|
-
import { observe } from 'gs-dom/observer';
|
|
7
|
-
const ListenFlagKey = "__listen-tweet-flag-key";
|
|
8
|
-
class ListenFlag {
|
|
9
|
-
static #flag;
|
|
10
|
-
static get flag() {
|
|
11
|
-
return this.#flag || (this.#flag = self[ListenFlagKey]);
|
|
12
|
-
}
|
|
13
|
-
static isInit(arg) {
|
|
14
|
-
const init = !!this.flag;
|
|
15
|
-
return arg && this.update(arg), init;
|
|
16
|
-
}
|
|
17
|
-
static update(arg) {
|
|
18
|
-
self[ListenFlagKey] ? (arg?.enableTweetDetected && (self[ListenFlagKey].enableTweetDetected = !0), arg?.enableUserDetected && (self[ListenFlagKey].enableUserDetected = !0)) : Object.defineProperty(self, ListenFlagKey, {
|
|
19
|
-
value: { ...arg },
|
|
20
|
-
enumerable: !1,
|
|
21
|
-
configurable: !1,
|
|
22
|
-
writable: !1
|
|
23
|
-
}), this.#flag = self[ListenFlagKey];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const timelineRegex = /TweetDetail|Timeline|Bookmarks|UserTweets|UserMedia|Likes/, id = "__listen-tweet-interceptor";
|
|
27
|
-
function listenNet() {
|
|
28
|
-
addXhrInterceptor({
|
|
29
|
-
id,
|
|
30
|
-
before: (url) => timelineRegex.test(url) ? url : void 0,
|
|
31
|
-
after: (text) => {
|
|
32
|
-
const json = JSON.parse(text), { tweets, users, videos } = XParser.parseSimple(json);
|
|
33
|
-
if (videos?.length) try {
|
|
34
|
-
trigger(ListenTweetEvents.VideoDetected, { detail: videos });
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
const flag = ListenFlag.flag || {};
|
|
38
|
-
if (flag.enableTweetDetected && tweets?.length) try {
|
|
39
|
-
trigger(ListenTweetEvents.UserDetected, { detail: tweets });
|
|
40
|
-
} catch {
|
|
41
|
-
}
|
|
42
|
-
if (flag.enableUserDetected && users?.length) try {
|
|
43
|
-
trigger(ListenTweetEvents.UserDetected, { detail: users });
|
|
44
|
-
} catch {
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const containerSelector = "main,main *", regionSelector = 'main [data-testid="primaryColumn"] [role="region"]', cellSelector = `${regionSelector} [data-testid="cellInnerDiv"]`, itemSelector = `${cellSelector} [role="listitem"]`, tweetSelector = [cellSelector, itemSelector].join(",");
|
|
50
|
-
function addedElements(els) {
|
|
51
|
-
const tweets = [];
|
|
52
|
-
function processTarget(el) {
|
|
53
|
-
if (el.matches(tweetSelector)) {
|
|
54
|
-
const id2 = getTweetId(el);
|
|
55
|
-
id2 && tweets.push(id2);
|
|
56
|
-
} else el.matches(containerSelector) && el.clientHeight > 300 && els.push(...el.querySelectorAll(tweetSelector));
|
|
57
|
-
}
|
|
58
|
-
for (let i = 0; i < els.length; i++)
|
|
59
|
-
try {
|
|
60
|
-
processTarget(els[i]);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.warn(e);
|
|
63
|
-
}
|
|
64
|
-
tweets.length && trigger(ListenTweetEvents.TweetRendered, { detail: tweets });
|
|
65
|
-
}
|
|
66
|
-
function observePage() {
|
|
67
|
-
observe({ subtree: !0, addedElements });
|
|
68
|
-
}
|
|
69
|
-
function startListen(option) {
|
|
70
|
-
ListenFlag.isInit(option) || (listenNet(), observePage());
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
startListen
|
|
74
|
-
};
|