Twitterを少し便利に。

私の作ったスクリプトをまとめたもの。と追加要素。

目前为 2024-11-28 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Twitterを少し便利に。
  3. // @name:ja Twitterを少し便利に。
  4. // @name:en Make Twitter little useful.
  5. // @namespace https://gf.qytechs.cn/ja/users/1023652
  6. // @version 1.0.1.51
  7. // @description 私の作ったスクリプトをまとめたもの。と追加要素。
  8. // @description:ja 私の作ったスクリプトをまとめたもの。と追加要素。
  9. // @description:en A compilation of scripts I've made.
  10. // @author ゆにてぃー
  11. // @match https://twitter.com/*
  12. // @match https://mobile.twitter.com/*
  13. // @match https://x.com/*
  14. // @match https://X.com/*
  15. // @connect twitter.com
  16. // @connect api.twitter.com
  17. // @connect api.x.com
  18. // @connect api.fanbox.cc
  19. // @connect pbs.twimg.com
  20. // @connect abs.twimg.com
  21. // @connect video.twimg.com
  22. // @connect discord.com
  23. // @connect booth.pm
  24. // @connect carrd.co
  25. // @connect creatorlink.net
  26. // @connect fantia.jp
  27. // @connect html.co.jp
  28. // @connect linktr.ee
  29. // @connect lit.link
  30. // @connect potofu.me
  31. // @connect profcard.info
  32. // @connect skeb.jp
  33. // @connect sketch.pixiv.net
  34. // @connect tumblr.com
  35. // @connect twpf.jp
  36. // @connect lab.syncer.jp
  37. // @connect geek-website.com
  38. // @connect ci-en.dlsite.com
  39. // @connect dl.dropboxusercontent.com
  40. // @connect video-ft.twimg.com
  41. // @icon data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJkSURBVHgB7VZBbtpQEH3zIW0WVYuXVaH4Bs0NSk4AOUFhEarskhMknIDsqkKlcIT0BNAT1D1B3ZJK3dmVuirwp/MhVmzAxiagKBJv9+ePZ97M/JkxsMMODwzChlD84FWQp3MxeCDHAhiumB+MJrr1+8Ryw3p/9+H4DctfIPCq49Xlw8Kv99YlMuB19885gy/i7llziwGfFFWJyR02XzSCuwiBUse7BlFVaz5LS8KQVkRXaXRJsqImfDjKSZBNyzEyFWFKVJ4KFbWLElUao6KbSk8i9TXgTPaorxTskPwOxa7/9baGt4zg8oQbNyfWYJlRU0/KUx9ZwNwYNq1ecFRzl18QpW0bB0Ks//KjV1uwlbuLJA3GxEdh5wb5yGEPl3qMd2xecYQHKnlFlVLX95kxYCFKGg5IlU2a0uLpCM68LEJA+sJ/Dm6Jy3aMjQIRakRUm+UuvfOp/X34iQSejeFo0Hdx4optG5uFH/R+GHNvANcm3VtwLs+Lvy2TRwhIOnrYHhysIuDKcCDwGbYAjglOzQt+HssElF6dvoNNOZeuCSbfSgIGMjILMo4/ExZf7TqghNLmlwm1gpSC2tmaLAZMvWGz0Iu7XpqBm2NrQNN5cD+Y5ZOTdZyok3RZMusZOJUN+QZrQFb0oQkG6xIIYHe8A03Unx/Ryd6jS2ctAsbxmFRVynGKlM5na5ePVkUe0p+h9MmraS2zXqYgmSWjOPtElHbLTVB3Q79gqQlMScxqXpeav0UWiGMmXKSNOpZAAPvKs/U/1MRoxRxl+5WD+psUy2D5IdmRVoWjnqDnLlkyO+zwaPAf1zXwZL751PUAAAAASUVORK5CYII=
  42. // @grant GM_xmlhttpRequest
  43. // @grant GM_registerMenuCommand
  44. // @license MIT
  45. // @run-at document-idle
  46. // ==/UserScript==
  47.  
  48. (async function(){
  49. 'use strict';
  50.  
  51. const commonselectors = {
  52. 'tweet_field': 'article[data-testid="tweet"]',
  53. 'retweeted': '[data-testid="socialContext"]',
  54. 'liked_color': 'r-vkub15',
  55. 'liked': 'M20.884 13.19c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z',
  56. 'info_field': '.r-1d09ksm.r-1471scf.r-18u37iz.r-1wbh5a2',
  57. 'click_media_field': '.r-1p0dtai.r-1mlwlqe.r-1d2f490.r-dnmrzs.r-1udh08x.r-u8s1d.r-zchlnj.r-ipm5af.r-417010',
  58. 'profile_field_Header_Items': '[data-testid="UserProfileHeader_Items"]',
  59. 'link': {
  60. nomal: "css-1jxf684 r-bcqeeo r-1ttztb7 r-qvutc0 r-poiln3 r-1loqt21",
  61. hovered: "css-1jxf684 r-bcqeeo r-1ttztb7 r-qvutc0 r-poiln3 r-1ny4l3l r-1ddef8g r-tjvw6i r-1loqt21"
  62. },
  63. 'engagementsTextColor': {
  64. "0": {"count": "rgb(15, 20, 25)","text": "rgb(83, 100, 113)"},
  65. "1": {"count": "rgb(247, 249, 249)","text": "rgb(139, 152, 165)"},
  66. "2": {"count": "rgb(231, 233, 234)","text": "rgb(113, 118, 123)"},
  67. },
  68. };
  69. const desktop_selectors = {
  70. 'time_line_media_field': '.r-1p0dtai.r-1mlwlqe.r-1d2f490.r-11wrixw.r-61z16t.r-1udh08x.r-u8s1d.r-zchlnj.r-ipm5af.r-417010',
  71. 'media_field': '.r-9aw3ui.r-1s2bzr4',
  72. 'profileField': '.r-1ifxtd0.r-ymttw5.r-ttdzmv',
  73. 'followersLink': '.r-bcqeeo.r-qvutc0.r-1tl8opc.r-a023e6.r-rjixqe.r-16dba41.r-1loqt21',
  74. };
  75. const mobile_selectors = {
  76. 'time_line_media_field': '.r-1p0dtai.r-1mlwlqe.r-1d2f490.r-1udh08x.r-u8s1d.r-zchlnj.r-ipm5af.r-417010',
  77. 'media_field': '.r-9aw3ui.r-a1ub67 > .r-9aw3ui',
  78. 'profileField': '.r-ku1wi2.r-1j3t67a.r-1b3ntt7',
  79. 'followersLink': '.r-bcqeeo.r-qvutc0.r-1tl8opc.r-1b43r93.r-hjklzo.r-16dba41.r-1loqt21',
  80. };
  81. const deny_names = ["home", "explore", "notifications", "messages", "i", "settings", "tos", "privacy", "compose", "search"];
  82. const denyNamesRegex = new RegExp(`https?://(x|twitter)\\.com/(?!(${deny_names.join('|')})(?:\\?|/|$))[\\w]{3,}`, 'ig');
  83. let currentUrl = document.location.href;
  84. let updating = false;
  85. const userAgent = navigator.userAgent || navigator.vendor || window.opera;
  86. const timeZoneObject = Intl.DateTimeFormat().resolvedOptions();
  87. let env_selector;
  88. let isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
  89. if(isMobile){
  90. env_selector = {...commonselectors,...mobile_selectors};
  91. }else{
  92. env_selector = {...commonselectors,...desktop_selectors};
  93. }
  94. let fetchedTweets = {};
  95. let fetchedTweetsUserData = {};
  96. let fetchedTweetsUserDataByUserName = {};
  97. let isFunctionRunning = {
  98. Hello_tweet_where_are_you_from: false,
  99. Engagement_Restorer: false,
  100. Show_all_Medias: false,
  101. };
  102. let storedSettings = {
  103. 'Make_Twitter_little_useful': JSON.parse(localStorage.getItem('Make_Twitter_little_useful') || '{}'),
  104. 'webhook_brings_tweets_to_discord': JSON.parse(localStorage.getItem('webhook_brings_tweets_to_discord') || '{}'),
  105. 'Hello_tweet_where_are_you_from': JSON.parse(localStorage.getItem('Hello_tweet_where_are_you_from') || '{}'),
  106. 'Show_me_your_Pixiv': JSON.parse(localStorage.getItem('Show_me_your_Pixiv') || '{}'),
  107. 'Note_Tweet_expander': JSON.parse(localStorage.getItem('Note_Tweet_expander') || '{}'),
  108. 'sneakilyFavorite': JSON.parse(localStorage.getItem('sneakilyFavorite') || '{}'),
  109. 'Engagement_Restorer': JSON.parse(localStorage.getItem('Engagement_Restorer') || '{}'),
  110. 'Show_all_Medias': JSON.parse(localStorage.getItem('Show_all_Medias') || '{}'),
  111. 'quickShareTweetLink': JSON.parse(localStorage.getItem('quickShareTweetLink') || '{}'),
  112. };
  113. let script_settings = {};
  114. script_settings['webhook_brings_tweets_to_discord'] = {
  115. "displayMethod": storedSettings['webhook_brings_tweets_to_discord'].displayMethod || 'method1',
  116. "lang": storedSettings['webhook_brings_tweets_to_discord'].lang || GetCookie("lang") || 'en',
  117. "defaultWebhook": storedSettings['webhook_brings_tweets_to_discord'].defaultWebhook,
  118. "downloadVideo": storedSettings['webhook_brings_tweets_to_discord'].downloadVideo || false,
  119. "webHooks": (function(data){
  120. let webhooks = {};
  121. if(data && Array.isArray(data)){
  122. data.forEach(item => {
  123. if(item.name && item.value){
  124. webhooks[item.name] = item.value;
  125. }
  126. });
  127. }
  128. return webhooks;
  129. })(storedSettings['webhook_brings_tweets_to_discord'].data),
  130. };
  131. script_settings['Make_Twitter_little_useful'] = {
  132. "featuresToggle": {
  133. "webhook_brings_tweets_to_discord": storedSettings.Make_Twitter_little_useful?.featuresToggle?.webhook_brings_tweets_to_discord || false,
  134. "Engagement_Restorer": storedSettings.Make_Twitter_little_useful?.featuresToggle?.Engagement_Restorer || false,
  135. "sneakilyFavorite": storedSettings.Make_Twitter_little_useful?.featuresToggle?.sneakilyFavorite || false,
  136. "Hello_tweet_where_are_you_from": storedSettings.Make_Twitter_little_useful?.featuresToggle?.Hello_tweet_where_are_you_from || false,
  137. "Note_Tweet_expander": storedSettings.Make_Twitter_little_useful?.featuresToggle?.Note_Tweet_expander || false,
  138. "Show_me_your_Pixiv": storedSettings.Make_Twitter_little_useful?.featuresToggle?.Show_me_your_Pixiv || false,
  139. "showFollowers": storedSettings.Make_Twitter_little_useful?.featuresToggle?.showFollowers || false,
  140. "hideAnalytics": storedSettings.Make_Twitter_little_useful?.featuresToggle?.hideAnalytics || false,
  141. "quickShareTweetLink": storedSettings.Make_Twitter_little_useful?.featuresToggle?.quickShareTweetLink || false,
  142. "Show_all_Medias": storedSettings.Make_Twitter_little_useful?.featuresToggle?.Show_all_Medias || false,
  143. "show_me_big_pics": storedSettings.Make_Twitter_little_useful?.featuresToggle?.show_me_big_pics || false,
  144. "returnFavorites": storedSettings.Make_Twitter_little_useful?.featuresToggle?.returnFavorites || false,
  145. },
  146. "lang": storedSettings.Make_Twitter_little_useful?.featuresToggle?.lang || GetCookie("lang") || "en",
  147. };
  148. script_settings['Show_all_Medias'] = {
  149. "displayMethod": typeof storedSettings.Show_all_Medias?.displayMethod === 'number' ? storedSettings.Show_all_Medias.displayMethod : 1,
  150. "onlyRemoveBlur": storedSettings.Show_all_Medias?.onlyRemoveBlur || false,
  151. "removeBlur": storedSettings.Show_all_Medias?.removeBlur || false,
  152. }
  153. let scriptDataStore = {
  154. "Show_me_your_Pixiv": JSON.parse(localStorage.getItem('user_pixvi_link_collection') || "{}"),
  155. "Show_me_your_Pixiv_dataBase": (await getFromIndexedDB('Show_me_your_Pixiv','pixiv_link_collection_dataBase')|| {}),
  156. "Show_all_Medias": {},
  157. "createTwitterArticle": {},
  158. "returnFavorites": {}
  159. };
  160. let Text = {};
  161. Text.ja = {
  162. "settings": "の設定",
  163. "close": "閉じる",
  164. "general": "全体",
  165. "featureToggle": "使う機能の切り替え",
  166. "copied": "クリップボードにコピー",
  167. "style": {
  168. "functionName": "スタイル",
  169. },
  170. "Advanced": {
  171. "functionName": "高度な設定",
  172. "invalidJson": "不正なJSONです。",
  173. "ExportSettings": "設定の書き出し",
  174. "ImportSettings": "設定の読み込み",
  175. "Export": "エクスポート",
  176. "Inport": "インポート",
  177. },
  178. "ForDebug": {
  179. "functionName": "デバッグ用",
  180. "get": "取得",
  181. },
  182. "webhook_brings_tweets_to_discord": {
  183. "functionName": "WebhookがTweetを連れてくるわ今日も",
  184. "link_to_tweet": "ツイートへ",
  185. "link_to_image": "画像へのリンク",
  186. "engagement": "エンゲージメント",
  187. "likes": "いいね",
  188. "retweets": "リツイート",
  189. "units": "万",
  190. "roundingScale": 10000,
  191. "decimalPlaces": 2,
  192. "postedDate": "投稿日時",
  193. "quotedTweet": "↓♻️引用元♻️↓",
  194. "submit": "送信",
  195. "display_everywhere": "どこでも表示する",
  196. "tweet_details_only": "詳細表示したときだけ",
  197. "when_webhook_name_duplicate": "Webhookの名前が重複しています。",
  198. "cancel": "キャンセル",
  199. "save_settings": "設定を保存",
  200. "display_method": "表示方法",
  201. "default": "デフォルトの",
  202. "language": "送信時言語",
  203. "webhook_not_set": "ウェブフックが設定されていません。",
  204. "when_webhook_url_invalid": "正しいDiscordのWebhookのURLではありません。",
  205. "when_post_failed": "以下のURLのポストに失敗しました。",
  206. "various_links": "各種リンク",
  207. "Video_Download_Option": "動画をダウンロードしてファイルとして送信する",
  208. "complete": "完了",
  209. },
  210. "Engagement_Restorer": {
  211. "functionName": "返ってこい!リツイート欄!",
  212. "retweet": "リツイート",
  213. "quoted": "件の引用",
  214. "like": "いいね",
  215. "units": "万",
  216. "roundingScale": 10000,
  217. "decimalPlaces": 2,
  218. },
  219. "sneakilyFavorite": {
  220. "functionName": "こっそりいいね",
  221. "favorite": "いいね!",
  222. },
  223. "Hello_tweet_where_are_you_from": {
  224. "functionName": "あなたのツイートはどこから?",
  225. },
  226. "Note_Tweet_expander": {
  227. "functionName": "長いツイートをTLで展開",
  228. },
  229. "Show_me_your_Pixiv": {
  230. "functionName": "PixivのリンクをTweetに添えて",
  231. "collectionMethod": "Pixivリンクの収集方法",
  232. "everywhere": "どこでも",
  233. "atProfile": "プロフィールで",
  234. "never": "新規では収集しない",
  235. "faildAddPixivUrlList": "データのダウンロードに失敗しました",
  236. "successAddPixivUrlList": "データのダウンロードに成功しました",
  237. "addPixivUrlListTitle": "URL対応表をインポートする"
  238. },
  239. "showFollowers": {
  240. "functionName": "フォロワーを直接表示",
  241. },
  242. "hideAnalytics": {
  243. "functionName": "アナリティクスを非表示にする",
  244. },
  245. "Show_all_Medias": {
  246. "functionName": "メディア欄に全ての画像を表示",
  247. "units": "万",
  248. "roundingScale": 10000,
  249. "decimalPlaces": 2,
  250. "expand": "展開",
  251. "likeTweet": "ツイートのように",
  252. "removeBlur": "R-18のモザイクを削除(メディア欄のみ)",
  253. "onlyRemoveBlur": "モザイクの削除のみ",
  254. },
  255. "show_me_big_pics": {
  256. "functionName": "でかい画像を見せないさい"
  257. },
  258. "returnFavorites": {
  259. "functionName": "いいね欄を見る",
  260. "like": "いいね",
  261. "more": "更に読み込む"
  262. },
  263. "quickShareTweetLink": {
  264. "functionName": "ツイートリンクを素早くコピー",
  265. "selectDomain": "ドメインの選択",
  266. "other": "その他",
  267. "useOther": "その他のドメイン",
  268. }
  269. };
  270.  
  271. Text.en = {
  272. "settings": "Settings",
  273. "close": "Close",
  274. "general": "General",
  275. "featureToggle": "Feature Toggle",
  276. "copied": "Copied!",
  277. "style": {
  278. "functionName": "style",
  279. },
  280. "Advanced": {
  281. "functionName": "Advanced",
  282. "invalidJson": "Invalid JSON",
  283. "ExportSettings": "Export Settings",
  284. "ImportSettings": "Import Settings",
  285. "Export": "Export",
  286. "Inport": "Inport",
  287. },
  288. "ForDebug": {
  289. "functionName": "Debug",
  290. "get": "get",
  291. },
  292. "webhook_brings_tweets_to_discord": {
  293. "functionName": "webhook brings tweets to discord",
  294. "link_to_tweet": "To Tweet",
  295. "link_to_image": "Link to Image",
  296. "engagement": "Engagement",
  297. "likes": "Likes",
  298. "retweets": "Retweets",
  299. "units": "k",
  300. "roundingScale": 1000,
  301. "decimalPlaces": 1,
  302. "postedDate": "Posted Date",
  303. "quotedTweet": "↓♻️Quoted Tweet♻️↓",
  304. "submit": "submit",
  305. "display_everywhere": "Display everywhere",
  306. "tweet_details_only": "Tweet Details Only",
  307. "when_webhook_name_duplicate": "Duplicate webhook name.",
  308. "cancel": "cancel",
  309. "save_settings": "saveSettings",
  310. "display_method": "Display Method",
  311. "default": "default",
  312. "language": "use language when sending",
  313. "webhook_not_set": "Webhook is not set.",
  314. "when_webhook_url_invalid": "It is not a valid Discord Webhook URL.",
  315. "when_post_failed": "Failed to post the following URL.",
  316. "various_links": "Various Links",
  317. "Video_Download_Option": "Download videos and send them.",
  318. "complete": "OK",
  319. },
  320. "Engagement_Restorer": {
  321. "functionName": "Engagement Restorer",
  322. "retweet": "Retweets",
  323. "quoted": "Quotes",
  324. "like": "Likes",
  325. "units": "k",
  326. "roundingScale": 1000,
  327. "decimalPlaces": 1,
  328. },
  329. "sneakilyFavorite": {
  330. "functionName": "sneakilyFavorite",
  331. "favorite": "favorite!",
  332. },
  333. "Hello_tweet_where_are_you_from": {
  334. "functionName": "Hello tweet where are you from?",
  335. },
  336. "Note_Tweet_expander": {
  337. "functionName": "Note Tweet expander",
  338. },
  339. "Show_me_your_Pixiv": {
  340. "functionName": "Show me your Pixiv",
  341. "collectionMethod": "Pixiv link collection method",
  342. "everywhere": "Everywhere",
  343. "atProfile": "At profile",
  344. "never": "never",
  345. "faildAddPixivUrlList": "Faild download pixiv url list",
  346. "successAddPixivUrlList": "Success download pixiv url list",
  347. "addPixivUrlListTitle": "Importing URL correspondence table"
  348. },
  349. "showFollowers": {
  350. "functionName": "showFollowers",
  351. },
  352. "hideAnalytics": {
  353. "functionName": "hideAnalytics",
  354. },
  355. "Show_all_Medias": {
  356. "functionName": "Show all Medias",
  357. "units": "k",
  358. "roundingScale": 1000,
  359. "decimalPlaces": 1,
  360. "expand": "expand",
  361. "likeTweet": "like tweet",
  362. "removeBlur": "Remove R-18 blur (media section only)",
  363. "onlyRemoveBlur": "Only remove R-18 blur",
  364. },
  365. "show_me_big_pics": {
  366. "functionName": "show me big pics"
  367. },
  368. "returnFavorites": {
  369. "functionName": "returnFavorites",
  370. "like": "Like",
  371. "more": "more"
  372. },
  373. "quickShareTweetLink": {
  374. "functionName": "quick Share TweetLink",
  375. "selectDomain": "Select domain",
  376. "other": "Other",
  377. "useOther": "Use other domain",
  378. }
  379. };
  380.  
  381. let env_Text = Text[script_settings.lang] || Text.ja;
  382.  
  383. async function main(refresh = false){
  384. const selector = refresh ? 'article[data-testid="tweet"]' : 'article[data-testid="tweet"]:not([mtlu_checked="true"])';
  385. const tweets = Array.from(document.querySelectorAll(selector)).map(tweet => {
  386. tweet.setAttribute('mtlu_checked', "true");
  387. const link = tweet.querySelector(`[data-testid="User-Name"] a[aria-label], ${env_selector.info_field} a[aria-label]`);
  388. if(link){
  389. const match = link.href.match(/[\w]{1,}\.com\/[^/]+\/status\/(\d+)/);
  390. if(match){
  391. return { id: match[1], link: link.href, node: tweet, screenName: (tweet.querySelector('[data-testid="User-Name"]>div>div>a')?.href?.split("/")[3] || undefined) };
  392. }
  393. }
  394. }).filter(Boolean);
  395. //console.log(tweets)
  396. const featurestoggle = script_settings.Make_Twitter_little_useful.featuresToggle;
  397. const isTweetDetail = !!currentUrl.match(/[\w]{1,}\.com\/[\w]*\/status\/[0-9]*/);
  398. if(isTweetDetail && featurestoggle.Hello_tweet_where_are_you_from){
  399. Hello_tweet_where_are_you_from();
  400. }
  401. if(tweets && featurestoggle.Note_Tweet_expander){
  402. Note_Tweet_expander(tweets);
  403. }
  404. if(tweets && featurestoggle.Show_me_your_Pixiv){
  405. Show_me_your_Pixiv(tweets);
  406. }
  407. if(isTweetDetail && featurestoggle.Engagement_Restorer){
  408. Engagement_Restorer();
  409. }
  410. if(tweets && featurestoggle.sneakilyFavorite){
  411. sneakilyFavorite(tweets);
  412. }
  413. if(tweets && featurestoggle.webhook_brings_tweets_to_discord){
  414. webhook_brings_tweets_to_discord(tweets);
  415. }
  416. if(featurestoggle.showFollowers){
  417. showFollowers();
  418. }
  419. if(tweets && featurestoggle.hideAnalytics){
  420. hideAnalytics(tweets);
  421. }
  422. if(featurestoggle.quickShareTweetLink){
  423. quickShareTweetLink(tweets);
  424. }
  425. if(currentUrl.match(/[\w]{1,}\.com\/([\w]*\/media|search\?q\=.*&f=media)/) && featurestoggle.Show_all_Medias){
  426. Show_all_Medias(currentUrl);
  427. }
  428. /*
  429. if(featurestoggle.returnFavorites){
  430. returnFavorites();
  431. }
  432. */
  433. /*
  434. if(tweets && featurestoggle.show_me_big_pics){
  435. show_me_big_pics(tweets);
  436. }
  437. */
  438. //if(currentUrl.match(/https?:\/\/twitter\.com\/[\w]*\/status\/[0-9]*/))console.log(await waitForTweetData(extractTweetId(currentUrl)))
  439. }
  440. /*
  441. async function returnFavorites(){
  442. const urlPattern = /https:\/\/(x|twitter)\.com\/[^\/]{2,}(\/(with_replies|highlights|articles|media))?$/;
  443. const screenName = extractUserName(currentUrl);
  444. const residual_object = document.querySelector('.returnFavorites_display_button');
  445. if(residual_object){
  446. if(!residual_object.childNodes[0].href.includes(`${screenName}/likes`))residual_object.remove();
  447. }
  448. if(!urlPattern.test(currentUrl) || !screenName) return;
  449. const snapList = await wait_load_Element('[data-testid="ScrollSnap-List"]', 20, 30, 'querySelector');
  450. if(!snapList) return;
  451. if(snapList.querySelector(`[href="/${screenName}/likes"]`)) return;
  452. const functionsText = env_Text.returnFavorites;
  453. let night_mode = getDarkMode() || 0;
  454. let colors = {
  455. "fontColor": ['rgb(15, 20, 25)', 'rgb(247, 249, 249)', 'rgb(231, 233, 234)'][night_mode],
  456. "fontColorDark": ['rgb(83, 100, 113)', 'rgb(139, 152, 165)', 'rgb(113, 118, 123)'][night_mode],
  457. "backgroundColor": ['rgba(255,255,255,1.00)', 'rgb(21, 32, 43)', 'rgba(0, 0, 0, 1.00)'][night_mode],
  458. "borderBottomColor": ['rgb(239, 243, 244)', 'rgb(56, 68, 77)', 'rgb(47, 51, 54)'][night_mode],
  459. };
  460. const newButton = snapList.querySelector('[aria-selected="false"]').parentNode.cloneNode(true);
  461. newButton.classList.add('returnFavorites_display_button');
  462. newButton.querySelector('span').textContent = functionsText.like;
  463. newButton.querySelector('a').href = `/${screenName}/likes`;
  464. newButton.addEventListener('click', e => {
  465. e.preventDefault();
  466. if (document.querySelector('.returnFavorites_overlay')) return;
  467. createDisplayPlace();
  468. createArticles();
  469. });
  470. snapList.childNodes.forEach(e => {
  471. e.addEventListener('click', e => {
  472. const target = document.querySelector('.returnFavorites_overlay');
  473. if(target)target.remove();
  474. });
  475. });
  476. if(urlPattern.test(currentUrl) || screenName == extractUserName(currentUrl))snapList.appendChild(newButton);
  477.  
  478. async function createArticles(max_id = null) {
  479. const tweetList = await get1_1_favorite(screenName, max_id);
  480. const contentsContainer = document.querySelector('.returnFavorites_contents');
  481. if(tweetList.length <= 1 && [...tweetList][0] == max_id){
  482. customAlert("no more favorite");
  483. return "max";
  484. }
  485. for(let tweetID of tweetList){
  486. if(tweetID == max_id)continue;
  487. try {
  488. await createTwitterArticle(fetchedTweets[tweetID], tweetID, contentsContainer, false, 'returnFavorites');
  489. } catch (error) {
  490. console.error(error);
  491. console.error({ error: error, tweetData: fetchedTweets[tweetID] });
  492. }
  493. }
  494. const moreButton = document.createElement('button');
  495. moreButton.style.backgroundColor = 'rgb(29, 155, 240)';
  496. moreButton.style.borderRadius = '9999px';
  497. moreButton.style.minHeight = '2em';
  498. moreButton.style.minWidth = '5em';
  499. moreButton.style.alignSelf = 'center';
  500. moreButton.style.padding = '0px 1em 0px 1em'
  501. moreButton.style.cursor = 'pointer';
  502. moreButton.style.margin = '40px 0px 40px 0px';
  503. const moreButtonText = document.createElement('span');
  504. moreButtonText.style.color = 'rgb(255, 255, 255)';
  505. moreButtonText.style.height = '1em';
  506. moreButtonText.textContent = functionsText.more;
  507. moreButton.appendChild(moreButtonText);
  508. moreButton.addEventListener('click',async e=>{
  509. moreButton.disabled = true;
  510. let res = await createArticles([...tweetList].pop());
  511. moreButton.remove();
  512. });
  513. contentsContainer.appendChild(moreButton);
  514. main();
  515. }
  516.  
  517. function createDisplayPlace() {
  518. const targetElement = document.querySelector('[data-testid="primaryColumn"] section');
  519. const { overlay, contentsWrapper, contentsContainer } = createOverlay(targetElement);
  520.  
  521. window.addEventListener('scroll', () => {
  522. updateOverlayPosition(overlay, contentsWrapper, targetElement);
  523. });
  524.  
  525. window.addEventListener('resize', () => {
  526. updateOverlayPosition(overlay, contentsWrapper, targetElement);
  527. });
  528. function createOverlay(targetElement) {
  529. const rect = targetElement.getBoundingClientRect();
  530. const overlay = document.createElement('div');
  531. overlay.classList.add('returnFavorites_overlay');
  532. overlay.style.width = '100%';
  533. overlay.style.height = '100vh'; // オーバーレイ全体の高さをウィンドウの高さに設定
  534. overlay.style.top = '0';
  535. overlay.style.left = '0';
  536. overlay.style.backgroundColor = "rgba(0,0,0,0.5)"; // 半透明の背景色を設定
  537. overlay.style.position = 'fixed'; // 固定位置に変更
  538. overlay.style.pointerEvents = 'auto';
  539. overlay.style.overflow = 'hidden'; // オーバーレイ全体のスクロールを無効にする
  540. overlay.style.transition = "top 0.3s ease, width 0.3s ease";
  541. overlay.style.cursor = 'default';
  542. overlay.style.zIndex = '1000';
  543. overlay.addEventListener('click', (e) => {
  544. e.stopPropagation();
  545. overlay.remove();
  546. });
  547.  
  548.  
  549. const contentsWrapper = document.createElement('div');
  550. contentsWrapper.style.width = `${rect.width}px`;
  551. contentsWrapper.style.height = 'calc(100vh - 30px)'; // 30px を除いた高さ
  552. contentsWrapper.style.overflow = 'hidden'; // コンテンツのスクロールを無効にする
  553. contentsWrapper.style.margin = '30px auto 30px auto'; // 上部に30pxの余白を設定
  554. contentsWrapper.style.backgroundColor = colors.backgroundColor;
  555. contentsWrapper.addEventListener('click', (e) => {
  556. e.stopPropagation();
  557. });
  558. const contentsContainer = document.createElement('div');
  559. contentsContainer.classList.add('returnFavorites_contents');
  560. contentsContainer.style.width = '100%';
  561. contentsContainer.style.height = '100%';
  562. contentsContainer.style.display = 'block';
  563. contentsContainer.style.overflowY = 'auto'; // コンテンツのスクロールを有効にする
  564.  
  565. contentsWrapper.appendChild(contentsContainer);
  566. overlay.appendChild(contentsWrapper);
  567.  
  568. document.body.appendChild(overlay);
  569.  
  570. // contentsContainer 内でスクロールイベントをキャプチャして、ページ全体のスクロールを防ぐ
  571. contentsContainer.addEventListener('wheel', (e) => {
  572. if (
  573. (contentsContainer.scrollTop === 0 && e.deltaY < 0) ||
  574. (contentsContainer.scrollTop + contentsContainer.clientHeight >= contentsContainer.scrollHeight && e.deltaY > 0)
  575. ) {
  576. e.preventDefault();
  577. }
  578. }, { passive: false });
  579.  
  580. return { overlay, contentsWrapper, contentsContainer };
  581. }
  582.  
  583. function updateOverlayPosition(overlay, contentsWrapper, targetElement) {
  584. const rect = targetElement.getBoundingClientRect();
  585. const topPosition = Math.max(rect.top + window.scrollY, 30);
  586. overlay.style.top = `${topPosition}px`;
  587.  
  588. // ウィンドウの上部30pxに達した場合に幅を100%に変更
  589. if (window.scrollY >= rect.top + window.scrollY - 30) {
  590. overlay.style.width = '100%';
  591. overlay.style.left = '0';
  592. overlay.style.pointerEvents = 'none'; // 透明部分はクリック可能にする
  593. contentsWrapper.style.width = `${rect.width}px`;
  594. contentsWrapper.style.margin = '30px auto 0';
  595. contentsContainer.style.overflowY = 'auto'; // コンテンツのスクロールを有効にする
  596. } else {
  597. overlay.style.width = `${rect.width}px`;
  598. overlay.style.left = `${rect.left + window.scrollX}px`;
  599. overlay.style.pointerEvents = 'auto'; // オーバーレイ内は相互作用可能にする
  600. contentsContainer.style.overflowY = 'auto'; // コンテンツのスクロールを有効にする
  601. }
  602. }
  603. }
  604. async function get1_1_favorite(screen_name = undefined,since_id = null){
  605. if(!screen_name) return;
  606. try{
  607. let response = await request(new requestObject_twitter_api_v1_1_favorites(screen_name,since_id));
  608. console.log(response)
  609. if(!response.status === "200")throw new Error(`Failed to fetch`);
  610. const idStrSet = new Set();
  611. response.response.forEach((tweetData)=>{
  612. if(tweetData.quoted_status){
  613. let quoted = tweetData.quoted_status;
  614. if(!(fetchedTweetsUserData[quoted.user.id_str]?.API_type === "graphQL")){
  615. fetchedTweetsUserData[quoted.user.id_str] = {...quoted.user,"API_type": "1_1"};
  616. fetchedTweetsUserDataByUserName[quoted.user.screen_name] = fetchedTweetsUserData[quoted.user.id_str];
  617. }
  618. quoted.user = fetchedTweetsUserData[quoted.user.id_str];
  619. if(!(fetchedTweets[quoted.id_str]?.API_type === "graphQL")){
  620. fetchedTweets[quoted.id_str] = {...quoted,"API_type": "1_1"};
  621. }
  622. tweetData.quoted_status = fetchedTweets[quoted.id_str];
  623. }
  624. if(!(fetchedTweetsUserData[tweetData.user.id_str]?.API_type === "graphQL")){
  625. fetchedTweetsUserData[tweetData.user.id_str] = {...tweetData.user,"API_type": "1_1"};
  626. fetchedTweetsUserDataByUserName[tweetData.user.screen_name] = fetchedTweetsUserData[tweetData.user.id_str];
  627. }
  628. tweetData.user = fetchedTweetsUserData[tweetData.user.id_str];
  629. fetchedTweets[tweetData.id_str] = {...tweetData,"API_type": "1_1"};
  630. idStrSet.add(tweetData.id_str);
  631. });
  632. return new Set(Array.from(idStrSet).sort((a, b) => b.localeCompare(a)));
  633. }catch(error){
  634. console.error(error);
  635. customAlert('List fetch failed');
  636. }
  637. }
  638. }
  639. */
  640. async function show_me_big_pics(tweets){
  641. tweets.forEach(tweet=>{
  642. const imgNode = tweet.node.querySelectorAll(`${env_selector.media_field} .r-16y2uox.r-1pi2tsx.r-13qz1uu a [data-testid="tweetPhoto"] img`);
  643. if(!imgNode)return;
  644. imgNode.forEach(async (node)=>{
  645. const imageUrl = node.src;
  646. node.src = imageUrl.replace(/\&name\=.*/,'&name=orig');
  647. });
  648. });
  649. }
  650. async function Show_all_Medias(triggeredUrl){
  651. if(isFunctionRunning.Hello_tweet_where_are_you_from)return;
  652. isFunctionRunning.Hello_tweet_where_are_you_from = true;
  653. try{
  654. if(script_settings.Show_all_Medias.displayMethod === 0 || script_settings.Show_all_Medias.onlyRemoveBlur){
  655. expand();
  656. }else{
  657. likeTweet();
  658. }
  659. }catch(error){
  660. console.error(error);
  661. }finally{
  662. isFunctionRunning.Hello_tweet_where_are_you_from = false;
  663. }
  664. script_settings.Show_all_Medias.removeBlur
  665. function expand(){
  666. const mediaPlace = document.querySelector('[data-testid="primaryColumn"] section');
  667. const madiaRow = mediaPlace.querySelectorAll(`.r-18u37iz.r-9aw3ui.r-1537yvj.r-14gqq1x:not(.Show_all_Medias_checked)`);
  668. const blurSvgPath = 'path[d="M3.693 21.707l-1.414-1.414 2.429-2.429c-2.479-2.421-3.606-5.376-3.658-5.513l-.131-.352.131-.352c.133-.353 3.331-8.648 10.937-8.648 2.062 0 3.989.621 5.737 1.85l2.556-2.557 1.414 1.414L3.693 21.707zm-.622-9.706c.356.797 1.354 2.794 3.051 4.449l2.417-2.418c-.361-.609-.553-1.306-.553-2.032 0-2.206 1.794-4 4-4 .727 0 1.424.192 2.033.554l2.263-2.264C14.953 5.434 13.512 5 11.986 5c-5.416 0-8.258 5.535-8.915 7.001zM11.986 10c-1.103 0-2 .897-2 2 0 .178.023.352.067.519l2.451-2.451c-.167-.044-.341-.067-.519-.067zm10.951 1.647l.131.352-.131.352c-.133.353-3.331 8.648-10.937 8.648-.709 0-1.367-.092-2-.223v-2.047c.624.169 1.288.27 2 .27 5.415 0 8.257-5.533 8.915-7-.252-.562-.829-1.724-1.746-2.941l1.438-1.438c1.53 1.971 2.268 3.862 2.33 4.027z"]';
  669. if(madiaRow.length === 0)return;
  670. const screenName = currentUrl.split('/')[3];
  671. madiaRow.forEach(n=>{
  672. n.classList.add('Show_all_Medias_checked');
  673. n.style.flexWrap = 'wrap';
  674. });
  675. const mediaNodes = Array.from(mediaPlace.querySelectorAll(`li:not(.Show_all_Medias_checked)`)).filter(node => {
  676. node.classList.add('Show_all_Medias_checked');
  677. const blurSvgNode = node.querySelector(blurSvgPath);
  678. if(script_settings.Show_all_Medias.removeBlur && blurSvgNode){
  679. blurSvgNode.parentNode.parentNode.parentNode.querySelector('[role="button"]').click();
  680. }
  681. return node.querySelector('path[d="M2 8.5C2 7.12 3.12 6 4.5 6h11C16.88 6 18 7.12 18 8.5v11c0 1.38-1.12 2.5-2.5 2.5h-11C3.12 22 2 20.88 2 19.5v-11zM19.5 4c.28 0 .5.22.5.5v13.45c1.14-.23 2-1.24 2-2.45v-11C22 3.12 20.88 2 19.5 2h-11c-1.21 0-2.22.86-2.45 2H19.5z"]');
  682. });
  683. if(mediaNodes.length === 0 || script_settings.Show_all_Medias.onlyRemoveBlur)return;
  684. mediaNodes.forEach(node => {
  685. const svgElement = node.querySelector('svg');
  686. const numberSpan = document.createElement('span');
  687. numberSpan.textContent = '1';
  688. numberSpan.style.position = 'absolute';
  689. numberSpan.style.color = 'black';
  690. numberSpan.style.left = 'calc(87.3%)';
  691. numberSpan.style.top = 'calc(86.3%)';
  692. numberSpan.className = 'indexNum';
  693. svgElement.parentNode.appendChild(numberSpan);
  694. });
  695. mediaNodes.forEach(async n=>{
  696. n.classList.add('Show_all_Medias_checked');
  697. const parent = n.parentNode;
  698. const mediaLinkNode = n.querySelector('a');
  699. const tweetID = mediaLinkNode.href.match(/[\w]{1,}\.com\/[^/]+\/status\/(\d+)/)[1];
  700. if(!fetchedTweets[tweetID])await fetchAndProcessTwitterApi('userMedia',screenName);
  701. const tweetData = await getTweetData(tweetID,"graphQL");
  702. const mediaData = tweetData.legacy.entities.media;
  703. if(mediaData.length == 1)return;
  704. let beforeNode = n;
  705. for(let i = 1;i<mediaData.length;i++){
  706. const currentMedia = mediaData[i];
  707. const currentImage = currentMedia.media_url_https;
  708. const currentImageExtention = currentImage.split('.').pop();
  709. const clonedNode = n.cloneNode(true);
  710. const clonedNodeLinkNode = clonedNode.querySelector('a');
  711. const clonedNodeImage = clonedNodeLinkNode.querySelector('img');
  712. const clonedNodeDisplayImage = clonedNodeImage.previousElementSibling;
  713. clonedNode.id = clonedNode.id + `_${i+1}`;
  714. if(!currentMedia.type === "photo")clonedNodeLinkNode.appendChild(makeVideoDurationElement(currentMedia.video_info?.duration_millis,(currentMedia.type === "animated_gif")));
  715. clonedNodeLinkNode.href = `https://twitter.com/${screenName}/status/${tweetID}/${currentMedia.type === "video" ? 'video' : 'photo'}/${i+1}`;
  716. clonedNodeImage.src = `${currentImage.replace('.' + currentImageExtention,'')}?format=${currentImageExtention}&name=orig`;
  717. clonedNodeDisplayImage.style.backgroundImage = `url(${currentImage.replace('.' + currentImageExtention,'')}?format=${currentImageExtention}&name=small)`;
  718. clonedNodeLinkNode.addEventListener('click',e=>{
  719. e.preventDefault();
  720. displayTarget(mediaLinkNode,i);
  721. });
  722. clonedNode.querySelector('.indexNum').textContent = (i+1);
  723. parent.insertBefore(clonedNode, beforeNode.nextSibling);
  724. beforeNode = clonedNode;
  725. const blurSvgNode = clonedNode.querySelector(blurSvgPath);
  726. if(blurSvgNode){
  727. const tmpNode = blurSvgNode.parentNode.parentNode.parentNode;
  728. tmpNode.querySelector('[role="button"]').addEventListener('click',e=>{
  729. const tmpNode2 = tmpNode.parentNode.querySelector('div');
  730. tmpNode.remove();
  731. tmpNode2.className = tmpNode2.classList[0];
  732. });
  733. }
  734. }
  735. });
  736. }
  737. function likeTweet(){
  738. const mediaPlace = document.querySelector('[data-testid="primaryColumn"] section');
  739. const madiaRow = mediaPlace?.querySelectorAll(`.r-18u37iz.r-9aw3ui.r-1537yvj.r-14gqq1x`);
  740. if(!(madiaRow?.length > 0))return;
  741. let mediaNodes = [];
  742. madiaRow.forEach(node => {
  743. if(!node.querySelector('[Show_all_Medias_Check="true"]')){
  744. const checkNode = document.createElement('div');
  745. checkNode.setAttribute('Show_all_Medias_Check','true');
  746. node.appendChild(checkNode);
  747. node.style.flexWrap = 'wrap';
  748. node.style.padding = '0px';
  749. node.style.margin = '0px';
  750. node.style.gap = '0px';
  751. mediaNodes.push(...node.querySelectorAll('li'));
  752. }
  753. });
  754. if(mediaNodes.length === 0)return;
  755. const processNode = async (n)=>{
  756. const mediaLinkNode = n.querySelector('a');
  757. const tweetID = mediaLinkNode.href.match(/[\w]{1,}\.com\/[^/]+\/status\/(\d+)/)[1];
  758. const screenName = mediaLinkNode.href.match(/[\w]{1,}\.com\/(\w+)/)[1];
  759. if(!fetchedTweets[tweetID]){
  760. if(triggeredUrl.match(/[\w]{1,}\.com\/([\w]*\/media)/))await fetchAndProcessTwitterApi('userMedia', screenName);
  761. //if(triggeredUrl.match(/search\?q\=.*&f=media/))await fetchAndProcessTwitterApi('mediaSearch', (new URL(triggeredUrl)).searchParams.get('q'));
  762. }
  763. n.style.width = "100%";
  764. let tweetData = await getTweetData(tweetID, "graphQL");
  765. if(n.querySelector('path[d="M2 8.5C2 7.12 3.12 6 4.5 6h11C16.88 6 18 7.12 18 8.5v11c0 1.38-1.12 2.5-2.5 2.5h-11C3.12 22 2 20.88 2 19.5v-11zM19.5 4c.28 0 .5.22.5.5v13.45c1.14-.23 2-1.24 2-2.45v-11C22 3.12 20.88 2 19.5 2h-11c-1.21 0-2.22.86-2.45 2H19.5z"]')){
  766. if(!(tweetData.extended_entities?.media?.length >= 2))tweetData = await getTweetData(tweetID, "graphQL");
  767. }
  768. let article = await createTwitterArticle(tweetData, tweetID, n, true);
  769. try{
  770. const articleImages = article.querySelectorAll('[data-testid="tweetPhoto"]');
  771. for(let i=0; i<articleImages.length; i++){
  772. if(articleImages[i].querySelector('img')){
  773. articleImages[i].addEventListener('click', e=>{
  774. e.preventDefault();
  775. displayTarget(mediaLinkNode, i);
  776. });
  777. }
  778. }
  779. article.addEventListener('click',async e=>{
  780. const ctaIdValues = ['Name-Place', 'mediaRoot', 'footer', 'quoted-place'];
  781. if(e.target.tagName === 'A' || e.target.closest('a'))return;
  782. const hasCtaId = ctaIdValues.some(ctaIdValue =>
  783. e.target.getAttribute('cta-id') === ctaIdValue || e.target.closest(`[cta-id="${ctaIdValue}"]`)
  784. );
  785. if(hasCtaId)return;
  786. mediaLinkNode.click();
  787. if(isMobile){
  788.  
  789. }else{
  790. (await wait_load_Element(`div[data-viewportview="true"] a[href="/${screenName}/status/${tweetID}"]`,20,50,'querySelector')).click()
  791. }
  792. });
  793. }catch(error){
  794. console.error(error);
  795. }
  796. n.firstChild.style.display = "none";
  797. n.appendChild(article);
  798. };
  799. Promise.all(Array.from(mediaNodes).map(n => processNode(n)));
  800. }
  801. async function displayTarget(node,page){
  802. node.click();
  803. await wait_load_Element('[data-testid="swipe-to-dismiss"]', 100, 25, 'querySelector');
  804. for(let i=1;i<=page;i++){
  805. simulateKey(39, 'keydown', document.body);
  806. //(await wait_load_Element('[data-testid="Carousel-NavRight"]', 100, 25, 'querySelector')).click();
  807. }
  808. }
  809. function makeVideoDurationElement(duration,isGif){
  810. let text;
  811. if(isGif){
  812. text = "GIF"
  813. }else{
  814. const durationSeconds = Math.floor(duration / 1000);
  815. const min = Math.floor(durationSeconds / 60);
  816. const sec = durationSeconds % 60;
  817. text = `${min}:${sec.toString().padStart(2, '0')}`;
  818. }
  819. const outerDiv = document.createElement('div');
  820. outerDiv.classList.add('r-1awozwy', 'r-k200y', 'r-z2wwpe', 'r-z80fyv', 'r-1777fci', 'r-s1qlax', 'r-13w96dm', 'r-1nlw0im', 'r-u8s1d', 'r-1r74h94', 'r-633pao');
  821.  
  822. const innerDiv = document.createElement('div');
  823. innerDiv.setAttribute('dir', 'ltr');
  824. innerDiv.style.color = 'rgb(255, 255, 255)';
  825. innerDiv.style.textOverflow = 'unset';
  826. innerDiv.classList.add('r-bcqeeo', 'r-qvutc0', 'r-1tl8opc', 'r-q4m81j', 'r-n6v787', 'r-1cwl3u0', 'r-16dba41', 'r-lrvibr');
  827.  
  828. const span = document.createElement('span');
  829. span.style.textOverflow = 'unset';
  830. span.classList.add('r-bcqeeo', 'r-qvutc0', 'r-1tl8opc');
  831. span.textContent = text;
  832.  
  833. innerDiv.appendChild(span);
  834. outerDiv.appendChild(innerDiv);
  835. return outerDiv;
  836. }
  837. }
  838. function quickShareTweetLink(tweetNodes){
  839. tweetNodes.forEach(async (tweet)=>{
  840. let color = ['rgb(83, 100, 113)','rgb(139, 152, 165)','rgb(113, 118, 123)'];
  841. let footer = tweet.node.querySelector('div[id][role="group"]');
  842. let caret = tweet.node.querySelector('[data-testid="caret"]').parentNode.parentNode;
  843. let clonedNode;
  844. if(caret){
  845. clonedNode = caret.cloneNode(true);
  846. //clonedNode.style.paddingTop = "1px";
  847. }else{
  848. clonedNode = footer.lastElementChild.cloneNode(true);
  849. }
  850. let svgClassList = footer.firstChild.querySelector('svg').classList;
  851. clonedNode.querySelector('button').setAttribute('data-testid','quickShare');
  852. clonedNode.style.marginLeft = "0.5em";
  853. clonedNode.style.justifyContent = 'inherit';
  854. clonedNode.style.display = 'inline-grid';
  855. clonedNode.style.transform = 'rotate(0deg) scale(1) translate3d(0px, 0px, 0px)';
  856. let clonedSvg = clonedNode.querySelector('svg');
  857. while(clonedSvg.firstChild){
  858. clonedSvg.removeChild(clonedSvg.firstChild);
  859. }
  860. let newPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  861. newPath.setAttribute('d', 'M17 4c-1.1 0-2 .9-2 2 0 .33.08.65.22.92C15.56 7.56 16.23 8 17 8c1.1 0 2-.9 2-2s-.9-2-2-2zm-4 2c0-2.21 1.79-4 4-4s4 1.79 4 4-1.79 4-4 4c-1.17 0-2.22-.5-2.95-1.3l-4.16 2.37c.07.3.11.61.11.93s-.04.63-.11.93l4.16 2.37c.73-.8 1.78-1.3 2.95-1.3 2.21 0 4 1.79 4 4s-1.79 4-4 4-4-1.79-4-4c0-.32.04-.63.11-.93L8.95 14.7C8.22 15.5 7.17 16 6 16c-2.21 0-4-1.79-4-4s1.79-4 4-4c1.17 0 2.22.5 2.95 1.3l4.16-2.37c-.07-.3-.11-.61-.11-.93zm-7 4c-1.1 0-2 .9-2 2s.9 2 2 2c.77 0 1.44-.44 1.78-1.08.14-.27.22-.59.22-.92s-.08-.65-.22-.92C7.44 10.44 6.77 10 6 10zm11 6c-.77 0-1.44.44-1.78 1.08-.14.27-.22.59-.22.92 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z');
  862. clonedSvg.appendChild(newPath);
  863. clonedSvg.style.color = color[getDarkMode()];
  864. clonedSvg.classList = svgClassList;
  865. clonedNode.addEventListener('click', () => {
  866. let useDomain = ['x.com', 'twitter.com', 'vxtwitter.com', 'ohter'][storedSettings.quickShareTweetLink?.domain] || " ";
  867. if(!(useDomain?.match(/(x\.com|twitter\.com|vxtwitter\.com)/))){
  868. if(storedSettings.quickShareTweetLink?.otherDomain){
  869. useDomain = storedSettings.quickShareTweetLink.otherDomain;
  870. }else{
  871. useDomain = "x.com";
  872. }
  873. }
  874. copyToClipboard(tweet.link.replace(/https?:\/\/(x|twitter)\.com/,`https://${useDomain}`));
  875. });
  876. function resetStyles() {
  877. clonedSvg.parentNode.firstChild.style.backgroundColor = '';
  878. clonedSvg.style.color = color[getDarkMode()];
  879. }
  880.  
  881. clonedNode.addEventListener('mouseover', function() {
  882. clonedSvg.parentNode.firstChild.style.backgroundColor = 'rgba(29, 155, 240, 0.1)';
  883. clonedSvg.style.color = 'rgb(29, 155, 240)';
  884. });
  885.  
  886. clonedNode.addEventListener('mouseout', resetStyles);
  887. clonedNode.addEventListener('touchend', resetStyles);
  888. clonedNode.addEventListener('touchcancel', resetStyles);
  889. clonedNode.addEventListener('click', (event) => {
  890. event.stopPropagation();
  891. });
  892. footer.appendChild(clonedNode);
  893. });
  894. }
  895. async function showFollowers(){
  896. try{
  897. if(!/\/verified_followers$/.test(currentUrl))return;
  898. const screenName = extractUserName(currentUrl);
  899. const safeScreenName = screenName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  900. const pattern = new RegExp(`${safeScreenName}/verified_followers$`);
  901. if(!pattern.test(currentUrl))return;
  902. const followersTab = await wait_load_Element(`a[role="tab"][href="/${screenName}/followers"]`,100,10,'querySelector');
  903. if(followersTab.getAttribute('showFollowersChecked') == "true")return;
  904. followersTab.click();
  905. followersTab.setAttribute('showFollowersChecked',"true");
  906. }catch(error){console.error(error)}
  907. /*
  908. try{
  909. const screenName = extractUserName(currentUrl);
  910. if(currentUrl.match(new RegExp(`${screenName}$`))){
  911. eventReplace(`${env_selector.profileField} ${env_selector.followersLink}`);
  912. }else if(isMobile&&(currentUrl === "https://twitter.com/home")){
  913. const profileIcon = (await wait_load_Element('[data-testid="DashButton_ProfileIcon_Link"]:not([showFollowersChecked="true"])',1000,2))[0];
  914. if(!profileIcon)return;
  915. profileIcon.setAttribute('showFollowersChecked',"true");
  916. profileIcon.addEventListener('click',async (event) => {
  917. eventReplace(env_selector.followersLink);
  918. });
  919. }
  920. }catch(error){console.error(error)}
  921. async function eventReplace(selector){
  922. (await wait_load_Element(selector,500,5)).forEach(e=>{
  923. if(e.href.match(/verified_followers$/)){
  924. e.href = e.href.replace(/verified_followers$/,'followers');
  925. e.addEventListener('click',async (event) => {
  926. (await wait_load_Element('a[role="tab"]')).forEach(t=>{
  927. if(t.href.match(/followers$/))t.click();
  928. });
  929. });
  930. }
  931. });
  932. }
  933. */
  934. }
  935. function hideAnalytics(tweetNodes){
  936. try{
  937. tweetNodes.forEach(t=>{
  938. if(t.id === extractTweetId(currentUrl))return;
  939. let analytics = t.node.querySelector('div[id][role="group"] a[role="link"]').parentNode || t.node.querySelector('[d="M8.75 21V3h2v18h-2zM18 21V8.5h2V21h-2zM4 21l.004-10h2L6 21H4zm9.248 0v-7h2v7h-2z"]').findParent('div.r-13awgt0.r-18u37iz.r-1h0z5md');
  940. analytics.style.display = "none";
  941. });
  942. }catch(error){console.error(error)}
  943. }
  944. async function webhook_brings_tweets_to_discord(tweetNodes){
  945. let textData = env_Text.webhook_brings_tweets_to_discord;
  946. let thisScriptSettings = script_settings['webhook_brings_tweets_to_discord'];
  947. tweetNodes.forEach(function(tweetNode){
  948. let element = tweetNode.node;
  949. if(element.querySelector(".quickDimg")) return;
  950. let tweet_link = tweetNode.link;
  951. let fotter = element.querySelector('div[id][role="group"]');
  952. const flexContainer = document.createElement('div');
  953. flexContainer.classList.add('quickDimg');
  954. flexContainer.style.display = 'flex';
  955.  
  956. // 1つ目のドロップダウン(サーバー選択)
  957. const dropdown_select_server = document.createElement('select');
  958. dropdown_select_server.className = "quickDimgPullDown quickDimgPullDown1";
  959. for(const server in thisScriptSettings.webHooks){
  960. const option = document.createElement('option');
  961. option.value = thisScriptSettings.webHooks[server];
  962. option.textContent = server;
  963. if(server == thisScriptSettings.defaultWebhook){
  964. option.selected = true;
  965. }
  966. dropdown_select_server.appendChild(option);
  967. }
  968. flexContainer.appendChild(dropdown_select_server);
  969. dropdown_select_server.addEventListener('click', (event) => {
  970. event.stopPropagation();
  971. });
  972.  
  973. const dropdown_send_image = document.createElement('select');
  974. dropdown_send_image.className = "quickDimgPullDown quickDimgPullDown2";
  975. for(let i = 1; i <= 5; i++){
  976. const option = document.createElement('option');
  977. option.value = i;
  978. option.textContent = i;
  979. if(i === 5){
  980. option.selected = true;
  981. }
  982. dropdown_send_image.appendChild(option);
  983. }
  984. flexContainer.appendChild(dropdown_send_image);
  985.  
  986. dropdown_send_image.addEventListener('click', (event) => {
  987. event.stopPropagation();
  988. });
  989. const dropdown_post_quote = document.createElement('select');
  990. dropdown_post_quote.className = "quickDimgPullDown quickDimgPullDown3";
  991. ['false','true'].forEach(value => {
  992. const option = document.createElement('option');
  993. option.value = value;
  994. option.textContent = value;
  995. dropdown_post_quote.appendChild(option);
  996. });
  997. flexContainer.appendChild(dropdown_post_quote);
  998.  
  999. dropdown_post_quote.addEventListener('click', (event) => {
  1000. event.stopPropagation();
  1001. });
  1002. /*
  1003. もういらない
  1004. const dropdown_use_graphql = document.createElement('select');
  1005. dropdown_use_graphql.className = "quickDimgPullDown quickDimgPullDown4";
  1006. ['false','true'].forEach(value => {
  1007. const option = document.createElement('option');
  1008. option.value = value;
  1009. option.textContent = value;
  1010. dropdown_use_graphql.appendChild(option);
  1011. });
  1012. flexContainer.appendChild(dropdown_use_graphql);
  1013.  
  1014. dropdown_use_graphql.addEventListener('click', (event) => {
  1015. event.stopPropagation();
  1016. });
  1017. */
  1018. // ボタンを作成
  1019. const button = document.createElement('button');
  1020. button.className = "quickDimgButton";
  1021. button.textContent = textData.submit;
  1022. flexContainer.appendChild(button);
  1023.  
  1024. function reEnableButton(){
  1025. button.disabled = false;
  1026. button.textContent = textData.submit;
  1027. }
  1028. dropdown_select_server.addEventListener('change', reEnableButton);
  1029. dropdown_send_image.addEventListener('change', reEnableButton);
  1030. dropdown_post_quote.addEventListener('change', reEnableButton);
  1031. //dropdown_use_graphql.addEventListener('change', reEnableButton);
  1032.  
  1033. // ボタンのクリックイベントを監視
  1034. button.addEventListener('click',async function(){
  1035. // ここでドロップダウンの選択値に基づいて処理を行う
  1036. this.disabled = true;
  1037. const selectedServer = dropdown_select_server.value;
  1038. const selectedNumber = dropdown_send_image.value;
  1039. const send_post_tweet = dropdown_post_quote.value === 'true';
  1040. //const useGraphql = dropdown_use_graphql.value === 'true';
  1041. if(!selectedServer){
  1042. customAlert(textData.webhook_not_set);
  1043. return;
  1044. }
  1045. let send_page;
  1046. if(selectedNumber != 5){
  1047. send_page = [selectedNumber-1]
  1048. }else{
  1049. send_page = [0,1,2,3];
  1050. }
  1051. const body = await make_send_data(tweet_link,send_page,send_post_tweet);
  1052. await sleep(300);
  1053. for(let target in body){
  1054. let formData = new FormData();
  1055. let payload = {};
  1056. let tmp = body[target];
  1057. if(tmp.embeds){
  1058. payload.embeds = tmp.embeds;
  1059. }
  1060. if(tmp.content){
  1061. payload.content = tmp.content;
  1062. }
  1063. formData.append('payload_json', JSON.stringify(payload));
  1064. //console.log(formData)
  1065. if(tmp.files){
  1066. tmp.files.forEach((file, index) => {
  1067. formData.append(`file${index}`, file.attachment, file.name);
  1068. });
  1069. }
  1070. try{
  1071. let res = await request(new sendObject_to_discord_webhook(selectedServer,formData),1,6000000);
  1072. if(res.statusText == "Bad Request"){
  1073. console.log({user: fetchedTweetsUserDataByUserName,tweets: fetchedTweets});
  1074. customAlert(`${textData.when_post_failed}`,payload.embeds[0].url);
  1075. }
  1076. }catch(error){
  1077. customAlert(`${textData.when_post_failed}`,payload.embeds[0].url);
  1078. console.log({user: fetchedTweetsUserDataByUserName,tweets: fetchedTweets});
  1079. console.log(error);
  1080. throw(error);
  1081. }
  1082. //console.log(res)
  1083. await sleep(1000);
  1084. }
  1085. button.textContent = textData.complete;
  1086. });
  1087. fotter.parentNode.appendChild(flexContainer);
  1088. });
  1089. async function make_send_data(tweet_link,select_pages = [1],send_quoted_tweet,use_graphQL){
  1090. const tweet_id = tweet_link.match(/https?:\/\/[\w]{1,}\.com\/\w+\/status\/(\d+)/)[1];
  1091. let textData = Text[script_settings.webhook_brings_tweets_to_discord.lang].webhook_brings_tweets_to_discord;
  1092. let tweet_data,quoted_data,return_object,apiType;
  1093. try{
  1094. /*
  1095. if(use_graphQL){
  1096. apiType = "graphQL";
  1097. }else{
  1098. apiType = "1_1"
  1099. }
  1100. */
  1101. tweet_data = await getTweetData(tweet_id,"graphQL");
  1102. quoted_data = tweet_data.quoted_status_result?.result || tweet_data.quoted_status;
  1103. return_object = await make_embeds();
  1104. }catch(error){
  1105. console.log({user: fetchedTweetsUserDataByUserName,tweets: fetchedTweets});
  1106. customAlert(`${textData.when_post_failed}`,tweet_link);
  1107. console.error(error);
  1108. }
  1109. if(send_quoted_tweet && quoted_data){
  1110. tweet_data = quoted_data;
  1111. return_object = return_object.concat([{content: textData.quotedTweet}],await make_embeds(1));
  1112. }
  1113. return return_object;
  1114. async function make_embeds(quoted_tweet_mode = 0){
  1115. let embeds = [];
  1116. let tmpEmbed = {};
  1117. let tmp_return_object = [];
  1118. let twitter_user_data = {};
  1119. let twitter_tweet_data = {};
  1120. let tweet_tweet_card_data = {};
  1121. let tweet_user_data_json = {};
  1122. let tweet_tweet_data_json = {};
  1123. let tweet_tweet_card_json = {};
  1124. tweet_user_data_json = tweet_data.core?.user_results?.result || tweet_data.user?.result || tweet_data.user;
  1125. tweet_tweet_data_json = tweet_data.legacy || tweet_data;
  1126. tweet_tweet_card_json = tweet_data.card?.legacy || tweet_data.card;
  1127. tweet_tweet_card_data.media = {images:[], videos:[]};
  1128. if(tweet_tweet_card_json){
  1129. tweet_tweet_card_json.binding_values?.forEach(v=>{
  1130. try{
  1131. let urlObj;
  1132. switch(v.key){
  1133. case 'broadcast_pre_live_slate':
  1134. tweet_tweet_card_data.broadcast_pre_live_slate = {media_type: "photo",url: v.value.image_value.url};
  1135. tweet_tweet_card_data.media.images.push(tweet_tweet_card_data.broadcast_pre_live_slate);
  1136. break;
  1137. case 'photo_image_full_size_original':
  1138. urlObj = new URL(v.value.image_value.url);
  1139. tweet_tweet_card_data.photo_image_full_size = {media_type: "photo",url: `${urlObj.origin}${urlObj.pathname}.${urlObj.searchParams.get('format') || 'jpg'}`};
  1140. tweet_tweet_card_data.media.images.push(tweet_tweet_card_data.photo_image_full_size);
  1141. break;
  1142. case 'unified_card':
  1143. tweet_tweet_card_data.unified_card = make_media_list({media: Object.values(JSON.parse(v.value.string_value).media_entities)},[0,1,2,3]);
  1144. if(tweet_tweet_card_data.unified_card.images){
  1145. tweet_tweet_card_data.media.images.push(...tweet_tweet_card_data.unified_card.images);
  1146. }
  1147. if(tweet_tweet_card_data.unified_card.videos){
  1148. tweet_tweet_card_data.media.videos.push(...tweet_tweet_card_data.unified_card.videos);
  1149. }
  1150. break;
  1151. default:
  1152. break;
  1153. }
  1154. }catch(error){
  1155. //console.error(v)
  1156. }
  1157. });
  1158. }
  1159. if(!(tweet_user_data_json&&tweet_tweet_data_json)){
  1160. tweet_data = await getTweetData(tweet_id,apiType,true);
  1161. tweet_user_data_json = tweet_data.core?.user_results?.result || tweet_data.user?.result || tweet_data.user;
  1162. tweet_tweet_data_json = tweet_data.legacy || tweet_data;
  1163. }
  1164. twitter_user_data.ID = tweet_user_data_json.rest_id || tweet_user_data_json.id_str;
  1165. twitter_user_data.screen_name = tweet_user_data_json.legacy?.screen_name || tweet_user_data_json.screen_name;
  1166. twitter_user_data.name = tweet_user_data_json.legacy?.name || tweet_user_data_json.name;
  1167. twitter_user_data.profile_image = (tweet_user_data_json.legacy?.profile_image_url_https || tweet_user_data_json.profile_image_url_https).replace(/(_normal|_x96)\./,'.');
  1168. twitter_user_data.urls = tweet_user_data_json.legacy?.entities || tweet_user_data_json.entities || [];
  1169. twitter_tweet_data.hashtags = tweet_tweet_data_json.entities.hashtags || [];
  1170. twitter_tweet_data.user_mentions = tweet_tweet_data_json.entities.user_mentions || [];
  1171. twitter_tweet_data.symbols = tweet_tweet_data_json.entities.symbols || [];
  1172. try{
  1173. await addPixivLinksToScriptDataStore([twitter_user_data.screen_name],true);
  1174. twitter_user_data.pixiv_url = getPixivUrlWithScreenName(twitter_user_data.screen_name);
  1175. }catch(error){
  1176. console.log("pixivのURLの取得に失敗しました。");
  1177. throw(error);
  1178. }
  1179. twitter_tweet_data.full_text = tweet_tweet_data_json.full_text || "";
  1180. twitter_tweet_data.extended_entities = tweet_tweet_data_json.extended_entities;
  1181. twitter_tweet_data.retweet_count = tweet_tweet_data_json.retweet_count;
  1182. twitter_tweet_data.favorite_count = tweet_tweet_data_json.favorite_count;
  1183. twitter_tweet_data.id = tweet_tweet_data_json.id_str;
  1184. twitter_tweet_data.created_at = new Date(tweet_tweet_data_json.created_at).toLocaleString(timeZoneObject.locale, { timeZone: timeZoneObject.timeZone });
  1185. twitter_tweet_data.urls = tweet_tweet_data_json.entities.urls;
  1186. twitter_tweet_data.media = make_media_list(twitter_tweet_data.extended_entities,select_pages);
  1187. twitter_tweet_data.media.images.push(...tweet_tweet_card_data.media.images);
  1188. twitter_tweet_data.media.videos.push(...tweet_tweet_card_data.media.videos);
  1189. try{
  1190. //文が長すぎるとエラーになるので一定の長さで切る。
  1191. //普通のツイートではそんなことありえないが、Blueでは長いツイートが可能なのでそれに対応している。
  1192. let note_tweet = tweet_data.note_tweet?.note_tweet_results.result;
  1193. twitter_tweet_data.full_text = note_tweet.text;
  1194. twitter_tweet_data.urls = note_tweet.entity_set.urls;
  1195. twitter_tweet_data.hashtags = get_only_particular_key_value(note_tweet.entity_set,"hashtags",[]);
  1196. twitter_tweet_data.user_mentions = get_only_particular_key_value(note_tweet.entity_set,"user_mentions",[]);
  1197. twitter_tweet_data.symbols = get_only_particular_key_value(note_tweet.entity_set,"symbols",[]);
  1198. }catch{}
  1199. //console.log(twitter_tweet_data.full_text)
  1200. // hashtags, mentions, symbolsを一つの配列に結合
  1201. let combined = [].concat(
  1202. twitter_tweet_data.hashtags.map(tag => ({
  1203. type: 'hashtag',
  1204. indices: tag.indices,
  1205. text: tag.text
  1206. })),
  1207. twitter_tweet_data.user_mentions.map(mention => ({
  1208. type: 'mention',
  1209. indices: mention.indices,
  1210. text: mention.screen_name
  1211. })),
  1212. twitter_tweet_data.symbols.map(symbol => ({
  1213. type: 'symbol',
  1214. indices: symbol.indices,
  1215. text: symbol.text
  1216. }))
  1217. );
  1218.  
  1219. // combinedをindicesの順にソート
  1220. combined.sort((a, b) => b.indices[0] - a.indices[0]);
  1221. let transformedText = twitter_tweet_data.full_text;
  1222. function countSurrogatePairs(str){
  1223. return Array.from(str).filter(char => char.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)).length;
  1224. }
  1225. const currentTimeMillis = new Date().getTime();
  1226. const linkTextStart = `linkTextStart${currentTimeMillis}`;
  1227. const linkTextEnd = `linkTextEnd${currentTimeMillis}`;
  1228. const linkUrlStart = `linkUrlStart${currentTimeMillis}`;
  1229. const linkUrlEnd = `linkUrlEnd${currentTimeMillis}`;
  1230. const hashtag = `hashtag${currentTimeMillis}`;
  1231. const underbarEscape = `underbarEscape${currentTimeMillis}`;
  1232. combined.forEach(item => {
  1233. let start = item.indices[0];
  1234. let end = item.indices[1];
  1235.  
  1236. // サロゲートペアの数をカウントして調整
  1237. const adjustment = countSurrogatePairs(transformedText.slice(0, end));
  1238. start += adjustment;
  1239. end += adjustment;
  1240. item.text = item.text.replace(/_/g, underbarEscape);
  1241. let replacement = '';
  1242. switch(item.type){
  1243. case 'hashtag':
  1244. replacement = `${linkTextStart}${hashtag}${item.text}${linkTextEnd}${linkUrlStart}https://twitter.com/hashtag/${item.text}${linkUrlEnd}`;
  1245. break;
  1246. case 'mention':
  1247. replacement = `${linkTextStart}@${item.text}${linkTextEnd}${linkUrlStart}https://twitter.com/${item.text}${linkUrlEnd}`;
  1248. break;
  1249. case 'symbol':
  1250. replacement = `${linkTextStart}$${item.text}${linkTextEnd}${linkUrlStart}https://twitter.com/search?q=%24${item.text}&src=cashtag_click${linkUrlEnd}`;
  1251. break;
  1252. }
  1253. transformedText = transformedText.slice(0, start) + replacement + transformedText.slice(end);
  1254. });
  1255. twitter_tweet_data.full_text = str_max_length(transformedText,7000);
  1256. //マークダウンにならないでほしいやつのエスケープ
  1257. let escapeCharacters = ['\\', '|', '*', '_', '`', '~', '[', ']', '(', ')', '>', '#', '-'];
  1258. escapeCharacters.forEach(char => {
  1259. let regExp = new RegExp('\\' + char, 'g');
  1260. twitter_tweet_data.full_text = twitter_tweet_data.full_text.replace(regExp, '\\' + char);
  1261. });
  1262. //マークダウンになって欲しいやつは戻す
  1263. twitter_tweet_data.full_text = twitter_tweet_data.full_text.replace(new RegExp(linkTextStart, 'g'), '[');
  1264. twitter_tweet_data.full_text = twitter_tweet_data.full_text.replace(new RegExp(linkTextEnd, 'g'), ']');
  1265. twitter_tweet_data.full_text = twitter_tweet_data.full_text.replace(new RegExp(linkUrlStart, 'g'), '(');
  1266. twitter_tweet_data.full_text = twitter_tweet_data.full_text.replace(new RegExp(linkUrlEnd, 'g'), ')');
  1267. twitter_tweet_data.full_text = twitter_tweet_data.full_text.replace(new RegExp(hashtag, 'g'), '#');
  1268. twitter_tweet_data.full_text = twitter_tweet_data.full_text.replace(new RegExp(underbarEscape, 'g'), '_');
  1269. /*
  1270. try{
  1271. if(select_pages.length > 1 && ! twitter_tweet_data.media.every(v => v.media_type == "photo")){
  1272. twitter_tweet_data.images = [twitter_tweet_data.media[0]];
  1273. }
  1274. }catch{}
  1275. try{
  1276. if(twitter_tweet_data.media.every(v => v.media_type.match(/(video|animated_gif)/))){
  1277. twitter_tweet_data.videos = [twitter_tweet_data.media[0]];
  1278. }
  1279. }catch{}
  1280. */
  1281. let tweet_url = `https://twitter.com/${twitter_user_data.screen_name}/status/${twitter_tweet_data.id}`;
  1282. /*
  1283. if(!quoted_tweet_mode == 1){
  1284. tweet_url = tweet_link;
  1285. }else{
  1286. tweet_url = `https://twitter.com/${twitter_user_data.screen_name}/status/${twitter_tweet_data.id}`;
  1287. }
  1288. */
  1289. tmpEmbed.color = 1940464;
  1290. tmpEmbed.title = "Tweet";
  1291. tmpEmbed.url = tweet_url;
  1292. tmpEmbed.author = {
  1293. "name": `${twitter_user_data.name} (@${twitter_user_data.screen_name})`,
  1294. "url": `https://twitter.com/${twitter_user_data.screen_name}`,
  1295. "icon_url": `attachment://profile_images.${((new URL(twitter_user_data.profile_image)).searchParams.get('format') || 'jpg')}`
  1296. };
  1297. tmpEmbed.description = replace_t_co_to_original_url(twitter_tweet_data.full_text,twitter_tweet_data.urls,twitter_tweet_data.media);
  1298. tmpEmbed.thumbnail = {"url": "https://pbs.twimg.com/profile_images/1488548719062654976/u6qfBBkF_400x400.jpg"};
  1299. tmpEmbed.fields = [
  1300. {
  1301. "name": `${textData.various_links}:link:`,
  1302. "value": `[${textData.link_to_tweet}](${tweet_url})` + `\n[TwitterID: ${twitter_user_data.ID}](https://twitter.com/intent/user?user_id=${twitter_user_data.ID})` + if_exsit_return_text(twitter_tweet_data.media[0]?.url,`\n[${textData.link_to_image}](${image_url_to_original(twitter_tweet_data.media[0]?.url)})`) + if_exsit_return_text(twitter_user_data.pixiv_url,`\n[Pixiv](${twitter_user_data.pixiv_url})`)
  1303. },{
  1304. "name": textData.engagement,
  1305. "value": `${textData.retweets} ${round_half_up(twitter_tweet_data.retweet_count,textData.roundingScale,textData.decimalPlaces,textData.units)}:recycle: ${textData.likes} ${round_half_up(twitter_tweet_data.favorite_count,textData.roundingScale,textData.decimalPlaces,textData.units)}:heart:`
  1306. },{
  1307. "name": textData.postedDate,
  1308. "value": twitter_tweet_data.created_at
  1309. }
  1310. ];
  1311. if(twitter_tweet_data.media.images[0]?.url){
  1312. tmpEmbed.image = {
  1313. "url": `attachment://${twitter_tweet_data.media.images[0].url.split('/').pop()}`
  1314. }
  1315. }
  1316. embeds.push(tmpEmbed);
  1317. if(twitter_tweet_data.media.images[1]?.url){
  1318. for(let i=1;i<twitter_tweet_data.media.images.length;i++){
  1319. embeds[i] = {
  1320. "url": tweet_url,
  1321. "image": {"url": `attachment://${twitter_tweet_data.media.images[i].url.split('/').pop()}`}
  1322. }
  1323. }
  1324. }
  1325. tmp_return_object.push({"embeds": embeds, "files": await fetchImages(twitter_tweet_data.media.images.concat([{"url": twitter_user_data.profile_image}]))});
  1326. if(twitter_tweet_data.media.videos?.length >= 1 && thisScriptSettings.downloadVideo){
  1327. const promises = twitter_tweet_data.media.videos.map(video => downloadVideo(video.url));
  1328. await Promise.all(promises)
  1329. .then(results => {
  1330. results.forEach(obj => {
  1331. tmp_return_object.push(obj);
  1332. });
  1333. })
  1334. .catch(error => {
  1335. console.error("Error downloading videos:", error);
  1336. });
  1337. }else if(twitter_tweet_data.media.videos?.length >= 1){
  1338. twitter_tweet_data.media.videos.forEach(video => {
  1339. tmp_return_object.push({"content": video.url});
  1340. });
  1341. }
  1342. return tmp_return_object;
  1343. }
  1344. function downloadVideo(url){
  1345. return new Promise(async (resolve) => {
  1346. //上限は「24117249」だったけどユーザーのアップロード上限が10MBになっちゃったので「10485760」にするかもしれない
  1347. //console.log((await request(new requestObject_binary_head(url))).responseHeaders);
  1348. const fileSize = await getFileSize(url);
  1349. if(fileSize < 24117249){
  1350. return resolve({"files": [{attachment: (await request(new requestObject_binary_data(url))).response, name: url.split('/').pop()}]});
  1351. }else{
  1352. const file = await request(new requestObject_binary_data(url)).response;
  1353. if(file.arrayBuffer() < 24117249)return resolve({"files": [{attachment: file, name: url.split('/').pop()}]});
  1354. return resolve({"content": url});
  1355. }
  1356. });
  1357. }
  1358. function extractUrls(entities){
  1359. let urls = [];
  1360. if(entities.description && entities.description.urls){
  1361. entities.description.urls.forEach(urlObj => {
  1362. urls.push(urlObj.expanded_url || urlObj.url);
  1363. });
  1364. }
  1365. if(entities.url && entities.url.urls){
  1366. entities.url.urls.forEach(urlObj => {
  1367. urls.push(urlObj.expanded_url || urlObj.url);
  1368. });
  1369. }
  1370. return urls;
  1371. }
  1372. function replace_t_co_to_original_url(full_text,urls,media_urls){
  1373. //ツイート内のt.coで短縮されたリンクをもとにのリンクにもどす。
  1374. try{
  1375. if(typeof full_text !== "undefined"){
  1376. full_text = decodeHtml(full_text);
  1377. if(typeof urls !== "undefined"){
  1378. for(let i=0;i<=urls.length-1;i++){
  1379. if(urls[i].expanded_url.length > 200){
  1380. full_text = full_text.replace(urls[i].url,`[${decodeURI(urls[i].expanded_url).slice(0,150)}](${decodeURI(urls[i].expanded_url)}) ... `);
  1381. }else{
  1382. full_text = full_text.replace(urls[i].url,decodeURI(urls[i].expanded_url));
  1383. }
  1384. }
  1385. }
  1386. //メディアがくっついてるツイートは末尾にメディアのURLが付随しているためそれを消す。
  1387. if(typeof media_urls !== "undefined"){
  1388. (media_urls.images || []).concat(media_urls.videos || []).forEach(u=>{
  1389. if(u.tco_url){
  1390. full_text = full_text.replace(u.tco_url,"");
  1391. }
  1392. });
  1393. }
  1394. }
  1395. }catch{}
  1396. return full_text;
  1397. }
  1398. function if_exsit_return_text(variable,return_text){
  1399. if(!(variable === null || variable === undefined || variable === "")){
  1400. return return_text
  1401. }
  1402. return "";
  1403. }
  1404. function make_media_list(extended_entities, select_pages){
  1405. var result = {images: [],videos: []};
  1406. if(extended_entities){
  1407. for(const target in select_pages){
  1408. try{
  1409. if(extended_entities.media.length > select_pages[target]){
  1410. let mediaItem = extended_entities.media[select_pages[target]];
  1411. let tmp_object = {media_type: mediaItem.type, tco_url: mediaItem.url};
  1412. if(tmp_object.media_type == "animated_gif" || tmp_object.media_type == "video"){
  1413. tmp_object.url = mediaItem.video_info.variants.filter(function(obj){return obj.content_type == "video/mp4";}).reduce((a, b) => a.bitrate > b.bitrate ? a : b).url.split('?')[0];
  1414. result.videos.push(tmp_object);
  1415. }else if(tmp_object.media_type == "photo"){
  1416. tmp_object.url = mediaItem.media_url_https;
  1417. result.images.push(tmp_object);
  1418. }
  1419. }
  1420. }catch(error){
  1421. console.error("メディアリストの作成に失敗しました。:\n" + error);
  1422. }
  1423. }
  1424. }
  1425. return result;
  1426. }
  1427. function str_max_length(text, max_length,defaultValue = "……以下Discordの字数オーバー。"){
  1428. var r = 0;
  1429. for(var i = 0; i < text.length; i++){
  1430. var c = text.charCodeAt(i);
  1431. if((c >= 0x0 && c < 0x81) || (c == 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)){
  1432. r += 1;
  1433. }else{
  1434. r += 2;
  1435. }
  1436. if(r >= max_length){
  1437. text = `${text.slice(0, i - 1)} ${defaultValue}`;
  1438. break;
  1439. }
  1440. }
  1441. return text;
  1442. }
  1443. function image_url_to_original(image_url){
  1444. //apiから帰ってくるURLをそのまま開くと小さい画像になってしまうので最大サイズの画像をダウンロードできるようにする。
  1445. if(typeof image_url !== "undefined"){
  1446. var extension = image_url.split(".").pop();
  1447. return `${image_url.replace(`.${extension}`,"")}?format=${extension}&name=orig`
  1448. }
  1449. }
  1450. async function fetchImages(mediaUrlArray){
  1451. if(mediaUrlArray?.length == 0) return;
  1452. let downloadPromises = mediaUrlArray.map(fetchImage);
  1453. return remove_null_from_array(await Promise.all(downloadPromises));
  1454. async function fetchImage(target) {
  1455. let retryCount = 5; // リトライ回数を設定
  1456. while(retryCount > 0){
  1457. if(!target.url) return;
  1458. let image;
  1459. let name;
  1460. if(target.url.match(/https?:\/\/pbs\.twimg\.com\/(media|card_img)\//)){
  1461. image = await request(new requestObject_binary_data(image_url_to_original(target.url)),3);
  1462. name = target.url.split('/').pop();
  1463. }else{
  1464. image = await request(new requestObject_binary_data(target.url),3);
  1465. name = "profile_images." + ((new URL(target.url)).searchParams.get('format') || 'jpg');
  1466. }
  1467.  
  1468. // ダウンロードした画像データのサイズを確認
  1469. if(image.response.size > 1025){
  1470. return {
  1471. "attachment": image.response,
  1472. "name": name,
  1473. };
  1474. }else{
  1475. retryCount--;
  1476. }
  1477. }
  1478. console.warn(`Failed to download image after multiple retries: ${target.url}`);
  1479. return null;
  1480. }
  1481. }
  1482. }
  1483. }
  1484. function sneakilyFavorite(tweetNodes){
  1485. tweetNodes.forEach(function(element){
  1486. const node = element.node;
  1487. if(node.querySelector(".sneakilyFavorite") || ! node.querySelector(env_selector.retweeted) || !node.querySelector('[data-testid="like"]')) return;
  1488. let tweet_link = element.link;
  1489. let button = document.createElement('button');
  1490. let fotter = node.querySelector('div[id][role="group"]');
  1491. let like_element = fotter.querySelector('[data-testid="like"]');
  1492. button.textContent = env_Text.sneakilyFavorite.favorite;
  1493. button.style.fontSize = '0.7em';
  1494. button.style.whiteSpace = 'nowrap';
  1495. button.classList.add('sneakilyFavorite');
  1496. button.addEventListener('click',async function(event){
  1497. this.disabled = true;
  1498. const status = await request(new requestObject_twitter_FavoriteTweet(tweet_link));
  1499. if(status.response.data.favorite_tweet == "Done"){
  1500. like_element.querySelector('div[dir="ltr"]').classList.add(env_selector.liked_color);
  1501. like_element.querySelector('div[dir="ltr"]').style.color = "rgb(249, 24, 128)";
  1502. like_element.querySelector("path").setAttribute('d',env_selector.liked);
  1503. like_element.setAttribute('data-testid', 'unlike');
  1504. }
  1505. this.remove();
  1506. });
  1507. fotter.insertBefore(button, like_element.parentElement.nextSibling);
  1508. });
  1509. }
  1510. async function Engagement_Restorer(){
  1511. if(!currentUrl.match(/https?\:\/\/[\w]{1,}\.com\/\w*\/status\/[0-9]*($|\?.*)/) || document.getElementById('restoreEngagements') || isFunctionRunning.Engagement_Restorer)return;
  1512. isFunctionRunning.Engagement_Restorer = true;
  1513. try{
  1514. const tweetLink = currentUrl.match(/https?\:\/\/[\w]{1,}\.com\/\w*\/status\/[0-9].*/)[0];
  1515. const tweetId = tweetLink.match(/\/status\/(\d+)/)[1];
  1516. const response = (await getTweetData(tweetId,"graphQL")).legacy;
  1517. const engagemants = {"favorite_count": response.favorite_count,"quote_count": response.quote_count,"retweet_count": response.retweet_count};
  1518. const target_node = Array.from((await wait_load_Element('article[data-testid="tweet"]',200,5))).find(node => {
  1519. const timeParents = Array.from(node.querySelectorAll('time')).map(time => time.parentNode);
  1520. return timeParents.some(parent => parent.href && parent.href.match(tweetId));
  1521. });
  1522. if(!target_node)return;
  1523. const engagemants_aria = target_node.querySelector('[role="group"]');
  1524. if(!engagemants_aria)return;
  1525. let envEngagementsTextColor = env_selector.engagementsTextColor[getDarkMode() || "0"];
  1526. const flexContainer = document.createElement('div');
  1527. flexContainer.style.display = 'flex';
  1528. flexContainer.style.justifyContent = 'space-between';
  1529. flexContainer.style.width = '70%';
  1530. flexContainer.id = 'restoreEngagements';
  1531. const links = [
  1532. {
  1533. "name": "retweets",
  1534. "href": tweetLink + "/retweets",
  1535. "count": round_half_up(engagemants.retweet_count,env_Text.Engagement_Restorer.roundingScale,env_Text.Engagement_Restorer.decimalPlaces,env_Text.Engagement_Restorer.units),
  1536. "text": env_Text.Engagement_Restorer.retweet
  1537. },
  1538. {
  1539. "name": "quotes",
  1540. "href": tweetLink + "/quotes",
  1541. "count": round_half_up(engagemants.quote_count,env_Text.Engagement_Restorer.roundingScale,env_Text.Engagement_Restorer.decimalPlaces,env_Text.Engagement_Restorer.units),
  1542. "text": env_Text.Engagement_Restorer.quoted,
  1543. },
  1544. {
  1545. "name": "likes",
  1546. "href": tweetLink + "/likes",
  1547. "count": round_half_up(engagemants.favorite_count,env_Text.Engagement_Restorer.roundingScale,env_Text.Engagement_Restorer.decimalPlaces,env_Text.Engagement_Restorer.units),
  1548. "text": env_Text.Engagement_Restorer.like,
  1549. },
  1550. ];
  1551. links.forEach((a, index) => {
  1552. const newLink = document.createElement('a');
  1553. newLink.style.textDecoration = 'none';
  1554. newLink.href = a.href;
  1555. const countText = document.createElement('span');
  1556. countText.textContent = a.count;
  1557. countText.style.color = envEngagementsTextColor.count;
  1558. newLink.appendChild(countText);
  1559.  
  1560. const textPart = document.createElement('span');
  1561. textPart.textContent = " " + a.text;
  1562. textPart.style.color = envEngagementsTextColor.text;
  1563. newLink.appendChild(textPart);
  1564.  
  1565. newLink.addEventListener('click', (e) => {
  1566. e.preventDefault();
  1567. clickTab(a.name,target_node);
  1568. });
  1569. flexContainer.appendChild(newLink);
  1570. });
  1571. if(currentUrl.match(/https?\:\/\/[\w]{1,}\.com\/\w*\/status\/[0-9]*($|\?.*)/))engagemants_aria.parentNode.prepend(flexContainer);
  1572. }catch(error){
  1573. console.error(error)
  1574. }finally{
  1575. isFunctionRunning.Engagement_Restorer = false;
  1576. }
  1577. async function clickTab(name,target_node){
  1578. target_node.querySelector('[data-testid="caret"]').click();
  1579. (await wait_load_Element('[data-testid="tweetEngagements"]',10,20,'querySelector')).click();
  1580. const engagemants_aria = (await wait_load_Element('nav[aria-live="polite"]',20,20,'querySelector'));
  1581. const regex = new RegExp(name + '$');
  1582. engagemants_aria.querySelectorAll('[role="presentation"] a').forEach((e)=>{
  1583. if(e.href.match(regex)) e.click();
  1584. });
  1585. }
  1586. }
  1587. async function Hello_tweet_where_are_you_from(){
  1588. if(document.querySelector('.display_twitter_client') || isFunctionRunning.Hello_tweet_where_are_you_from)return;
  1589. isFunctionRunning.Hello_tweet_where_are_you_from = true;
  1590. try{
  1591. const tweet_data = await getTweetData(extractTweetId(currentUrl),"graphQL");
  1592. const target_node = (await wait_load_Element(env_selector.info_field,300,4))[0];
  1593. const info_selector = target_node.childNodes[0].className;
  1594. let client_text = document.createElement("div");
  1595. client_text.dir = "ltr";
  1596. client_text.innerHTML = `<span class="display_twitter_client" style="">${tweet_data.source.replace(/<("[^"]*"|'[^']*'|[^'">])*>/g,'')}</span>`;
  1597. client_text.className = info_selector;
  1598. client_text.style.color = ["rgb(83, 100, 113)","rgb(139, 152, 165)","rgb(113, 118, 123)"][getDarkMode()];
  1599. target_node.appendChild(client_text);
  1600. client_text.className = "";
  1601. const media_data = tweet_data.legacy?.extended_entities?.media || tweet_data.extended_entities?.media;
  1602. if(!media_data)return;
  1603. const video_data = media_data.map((mediaItem, index) => {
  1604. if (['video', 'animated_gif'].includes(mediaItem.type)){
  1605. const highestBitrateVariant = mediaItem.video_info.variants.filter(obj => obj.content_type !== 'application/x-mpegURL').reduce((a, b) => a.bitrate > b.bitrate ? a : b);
  1606. return {
  1607. index: index,
  1608. url: highestBitrateVariant.url.split('?')[0]
  1609. };
  1610. }
  1611. }).filter(Boolean)
  1612. if(video_data.length === 0)return;
  1613. let show_video_url = document.createElement("span");
  1614. show_video_url.className = "display_video_url";
  1615. show_video_url.style.whiteSpace = "pre";
  1616. for(let video of video_data){
  1617. let video_url = makeLinkElement(video.url,`${video.index + 1}:video_url`);
  1618. show_video_url.appendChild(video_url);
  1619. if(video !== video_data[video_data.length - 1]){
  1620. show_video_url.appendChild(document.createTextNode(' '));
  1621. }
  1622. }
  1623. client_text.appendChild(document.createElement("br"));
  1624. client_text.appendChild(show_video_url);
  1625. }catch(error){
  1626. if(error === "Max retry count reached")return;
  1627. console.error(error);
  1628. }finally{
  1629. isFunctionRunning.Hello_tweet_where_are_you_from = false;
  1630. }
  1631. }
  1632.  
  1633. async function Note_Tweet_expander(tweetNodes){
  1634. const link_class = "css-1jxf684 r-bcqeeo r-1ttztb7 r-qvutc0 r-poiln3 r-1loqt21";
  1635. tweetNodes.forEach(async function(target){
  1636. const tweet_node = target.node;
  1637. if(tweet_node.getAttribute('cta-id') === 'returnFavorites'){
  1638. return;
  1639. }
  1640. const elements = tweet_node.querySelectorAll('[data-testid="tweetText"]');
  1641. const show_more_link = tweet_node.querySelectorAll('[data-testid="tweet-text-show-more-link"]');
  1642. if(show_more_link[0])show_more_link[0].style.display = "none";
  1643. if(show_more_link[1])show_more_link[1].style.display = "none";
  1644. elements.forEach(async (element,index) =>{
  1645. if(!(element.innerText.match(/…$/) || (show_more_link[index]?.tagName.toLowerCase() == "div"))){
  1646. element.classList.add('tweetExpanderChecked');
  1647. //if(element.innerText.split('\n').length >= 10)
  1648. element.style.webkitLineClamp = null;
  1649. return;
  1650. }
  1651. let tweet_id,tweet_data,note_tweet;
  1652. if(index == 0){
  1653. tweet_id = target.id;
  1654. tweet_data = await getTweetData(tweet_id,"graphQL");
  1655. note_tweet = tweet_data.note_tweet?.note_tweet_results.result || tweet_data.note_tweet?.note_tweet_results.result || null;
  1656. }else{
  1657. tweet_data = await getTweetData(target.id,"graphQL");
  1658. tweet_data = await getTweetData(tweet_data.legacy.quoted_status_id_str,"graphQL");
  1659. note_tweet = tweet_data.note_tweet?.note_tweet_results.result || tweet_data.note_tweet?.note_tweet_results.result || null;
  1660. }
  1661. if(!note_tweet){
  1662. element.style.webkitLineClamp = null;
  1663. element.classList.add('tweetExpanderChecked');
  1664. return;
  1665. }
  1666. const hashtags = note_tweet.entity_set?.hashtags || [];
  1667. const user_mentions = note_tweet.entity_set?.user_mentions || [];
  1668. const symbols = note_tweet.entity_set?.symbols || [];
  1669. const urls = note_tweet.entity_set?.urls;
  1670. let new_tweet_text = note_tweet.text;
  1671. function countSurrogatePairs(str){
  1672. return Array.from(str).filter(char => char.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)).length;
  1673. }
  1674. let combined = [].concat(
  1675. hashtags.map(tag => ({
  1676. type: 'hashtag',
  1677. indices: tag.indices,
  1678. text: tag.text
  1679. })),
  1680. user_mentions.map(mention => ({
  1681. type: 'mention',
  1682. indices: mention.indices,
  1683. text: mention.screen_name
  1684. })),
  1685. symbols.map(symbol => ({
  1686. type: 'symbol',
  1687. indices: symbol.indices,
  1688. text: symbol.text
  1689. }))
  1690. );
  1691. // combinedをindicesの順にソート
  1692. combined.sort((a, b) => b.indices[0] - a.indices[0]);
  1693. let transformedText = new_tweet_text;
  1694.  
  1695. combined.forEach(item => {
  1696. let start = item.indices[0];
  1697. let end = item.indices[1];
  1698.  
  1699. // サロゲートペアの数をカウントして調整
  1700. const adjustment = countSurrogatePairs(transformedText.slice(0, end));
  1701. start += adjustment;
  1702. end += adjustment;
  1703.  
  1704. let replacement = '';
  1705. switch(item.type){
  1706. case 'hashtag':
  1707. replacement = `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="https://twitter.com/hashtag/${item.text}" target="_blank" rel="noopener">#${item.text}</a>`;
  1708. break;
  1709. case 'mention':
  1710. replacement = `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="https://twitter.com/${item.text}" target="_blank" rel="noopener">@${item.text}</a>`;
  1711. break;
  1712. case 'symbol':
  1713. replacement = `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="https://twitter.com/search?q=%24${item.text}&src=cashtag_click" target="_blank" rel="noopener">$${item.text}</a>`;
  1714. break;
  1715. }
  1716. transformedText = transformedText.slice(0, start) + replacement + transformedText.slice(end);
  1717. });
  1718. new_tweet_text = transformedText;
  1719. const seen = new Set();
  1720. urls.filter(target => !seen.has(target.url) && seen.add(target.url)).forEach(target =>{
  1721. new_tweet_text = new_tweet_text.replace(new RegExp(`${target.url}(?=(\\s|$|\\u3000|\\W)(?!\\.|,))`, 'gu'), `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="${target.url}" target="_blank" rel="noopener">${target.display_url}</a>`);
  1722. });
  1723. var new_tweet_node = document.createElement("span");
  1724. new_tweet_node.className = 'css-901oao css-16my406 r-1tl8opc r-bcqeeo r-qvutc0';
  1725. new_tweet_node.innerHTML = new_tweet_text;
  1726. while(element.firstChild){
  1727. element.removeChild(element.firstChild);
  1728. }
  1729. element.appendChild(new_tweet_node);
  1730. element.style.webkitLineClamp = null;
  1731. });
  1732. });
  1733. }
  1734.  
  1735. async function Show_me_your_Pixiv(tweets){
  1736. const collectionMethod = storedSettings.Show_me_your_Pixiv?.showMeYourPixivCollectionMethod;
  1737. let todo = [];
  1738. tweets.forEach(tweet => {
  1739. const node = tweet.node.querySelector(`${env_selector.media_field},[cta-id="mediaContainer"]:not(.display_pixiv_link)`);
  1740. const screenName = tweet.screenName;
  1741. if(node){
  1742. todo.push({node:node,screenName:screenName});
  1743. }
  1744. });
  1745. let currentScreenName = extractUserName(currentUrl);
  1746. const uniqueScreenNames = [...new Set(todo.map(item => item.screenName))];
  1747. let promises = [];
  1748. if(currentScreenName && !(scriptDataStore?.Show_me_your_Pixiv?.lastGetUserScreenName == currentScreenName) && (collectionMethod === 0 || collectionMethod === 1 || !collectionMethod)){
  1749. (async()=>{
  1750. try{
  1751. const display_pixiv_link_in_profile_field = await wait_load_Element(`div.display_pixiv_link_in_profile`,100,5,'querySelector');
  1752. display_pixiv_link_in_profile_field.remove();
  1753. }catch{}
  1754. })();
  1755. scriptDataStore.Show_me_your_Pixiv.lastGetUserScreenName = currentScreenName;
  1756. promises.push(addPixivLinksToScriptDataStore([currentScreenName],true));
  1757. }
  1758. if(collectionMethod === 0)promises.push(addPixivLinksToScriptDataStore(uniqueScreenNames));
  1759. await Promise.all(promises);
  1760.  
  1761. todo.forEach(item => {
  1762. const node = item.node;
  1763. const screen_name = item.screenName;
  1764. const pixiv_url = getPixivUrlWithScreenName(screen_name);
  1765. if(pixiv_url && !(pixiv_url?.match(/(?:users\/|member.php\?id=)(11|9949830|15241365)(\/|$)/)) && node && !(node?.querySelector(".display_pixiv_link")))node.appendChild(makeLinkElement(pixiv_url,"Pixiv🔗","display_pixiv_link"));
  1766. });
  1767. if(getPixivUrlWithScreenName(currentScreenName) && !currentUrl.match(new RegExp(`${currentScreenName}/status`))){
  1768. const profile_field = (await wait_load_Element(env_selector.profile_field_Header_Items))[0];
  1769. currentScreenName = extractUserName(currentUrl);
  1770. let pixivUrl = getPixivUrlWithScreenName(currentScreenName);
  1771. if(profile_field && !profile_field.querySelector(`.display_pixiv_link_in_profile_${currentScreenName}`) && pixivUrl && !(pixivUrl?.match(/(?:users\/|member.php\?id=)(11|9949830|15241365)(\/|$)/))){
  1772. let display_pixiv_link_in_profile_field = document.createElement("div");
  1773. display_pixiv_link_in_profile_field.className = `display_pixiv_link_in_profile display_pixiv_link_in_profile_${currentScreenName}`;
  1774. let brElement = document.createElement("br");
  1775. display_pixiv_link_in_profile_field.appendChild(brElement);
  1776. display_pixiv_link_in_profile_field.appendChild(makeLinkElement(pixivUrl, "Pixiv🔗", "display_pixiv_link"));
  1777. profile_field.appendChild(display_pixiv_link_in_profile_field)
  1778. }
  1779. }
  1780. }
  1781.  
  1782. /////////////////////////////////////////////////////////////////////
  1783. ///////////////////////////ここから汎用関数///////////////////////////
  1784. /////////////////////////////////////////////////////////////////////
  1785. function update(){
  1786. if(updating) return;
  1787. updating = true;
  1788. //console.log({user: fetchedTweetsUserDataByUserName,tweets: fetchedTweets})
  1789. main();
  1790. setTimeout(() => {updating = false;}, 600);
  1791. }
  1792. function debug(log){
  1793. console.log(log);
  1794. }
  1795. function extractTweetId(url){
  1796. const match = url.match(/[\w]{1,}\.com\/[^/]+\/status\/(\d+)/);
  1797. return match ? match[1] : null;
  1798. }
  1799. function extractUserName(url){
  1800. const match = url.match(denyNamesRegex);
  1801. return match ? match[0].split('/')[3] : null;
  1802. }
  1803. function findParent(element, selector){
  1804. let current = element;
  1805. while(current !== null){
  1806. if(current.matches(selector)){
  1807. return current;
  1808. }
  1809. current = current.parentNode;
  1810. }
  1811. return null;
  1812. }
  1813. function locationChange(){
  1814. const observer = new MutationObserver(mutations => {
  1815. if(currentUrl !== document.location.href){
  1816. currentUrl = document.location.href;
  1817. try{
  1818. if(extractTweetId(currentUrl))getTweetData(extractTweetId(currentUrl),"graphQL");
  1819. if(extractUserName(currentUrl))getTweetData(extractUserName(currentUrl),"user");
  1820. }catch(error){console.error(error)}
  1821. addEventToScrollSnapSwipeableList();
  1822. main();
  1823. }
  1824. });
  1825. const target = document.getElementById("react-root");
  1826. const config = {childList: true,subtree: true};
  1827. observer.observe(target, config);
  1828. }
  1829. function copyToClipboard(text){
  1830. navigator.clipboard.writeText(text).then(function(){
  1831. displayToast(env_Text.copied);
  1832. }).catch(function(err) {
  1833. console.error('コピーに失敗しました:', err);
  1834. });
  1835. }
  1836. function simulateKey(keyCode, type, element) {
  1837. let event = new KeyboardEvent(type, {
  1838. key: keyCode,
  1839. keyCode: keyCode,
  1840. which: keyCode,
  1841. bubbles: true
  1842. });
  1843. element.dispatchEvent(event);
  1844. }
  1845. function makeLinkElement(href,text,additionalClass = ""){
  1846. let new_content = document.createElement("a");
  1847. new_content.style.color = "rgb(29, 155, 240)";
  1848. new_content.style.width = "fit-content";
  1849. new_content.href = href;
  1850. new_content.textContent = text;
  1851. new_content.className = `${additionalClass} css-1jxf684 r-bcqeeo r-1ttztb7 r-qvutc0 r-poiln3 r-1loqt21`;
  1852. new_content.target = "_blank";
  1853. new_content.rel = "noopener";
  1854. new_content.addEventListener('mouseenter', function(){
  1855. new_content.classList.add('r-1ny4l3l', 'r-1ddef8g', 'r-tjvw6i');
  1856. });
  1857. new_content.addEventListener('mouseleave', function(){
  1858. new_content.classList.remove('r-1ny4l3l', 'r-1ddef8g', 'r-tjvw6i');
  1859. });
  1860.  
  1861. return new_content;
  1862. }
  1863. async function addEventToScrollSnapSwipeableList(){
  1864. try{
  1865. if(!currentUrl.match(/home$/))return;
  1866. const element = await wait_load_Element('[data-testid="ScrollSnap-SwipeableList"]:not(.Make_Twitter_little_useful_do_main_function)',200,10,'querySelector');
  1867. element.classList.add("Make_Twitter_little_useful_do_main_function");
  1868. element.addEventListener("click", async () => {
  1869. await sleep(500);
  1870. update();
  1871. });
  1872. }catch{}
  1873. }
  1874. async function addEventToHomeButton(){
  1875. const element = await wait_load_Element('[data-testid="AppTabBar_Home_Link"]:not(.Make_Twitter_little_useful_do_main_function)',200,10,'querySelector');
  1876. element.classList.add("Make_Twitter_little_useful_do_main_function");
  1877. element.addEventListener("click", async ()=>{
  1878. update();
  1879. });
  1880. }
  1881. function wait_load_Element(Element_Name, interval = 100, retry = 25, searchFunction = 'querySelectorAll', searchPlace = document){
  1882. return new Promise((resolve, reject) => {
  1883. const MAX_RETRY_COUNT = retry;
  1884. let retry_counter = 0;
  1885. let set_interval_id = setInterval(find_target_element, interval);
  1886. let searchFn;
  1887. switch(searchFunction){
  1888. case 'querySelector':
  1889. searchFn = () => searchPlace.querySelector(Element_Name);
  1890. break;
  1891. case 'getElementById':
  1892. searchFn = () => searchPlace.getElementById(Element_Name);
  1893. break;
  1894. default:
  1895. searchFn = () => searchPlace.querySelectorAll(Element_Name);
  1896. }
  1897. function find_target_element(){
  1898. retry_counter++;
  1899. if(retry_counter > MAX_RETRY_COUNT){
  1900. clearInterval(set_interval_id);
  1901. return reject("Max retry count reached");
  1902. }
  1903. let target_elements = searchFn();
  1904. if((target_elements instanceof NodeList && target_elements.length > 0) || target_elements){
  1905. clearInterval(set_interval_id);
  1906. return resolve(target_elements);
  1907. }
  1908. }
  1909. });
  1910. }
  1911. function GetCookie(name){
  1912. let arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  1913. if(arr = document.cookie.match(reg)){
  1914. return decodeURIComponent(arr[2]);
  1915. }else{
  1916. return null;
  1917. }
  1918. }
  1919. function remove_null_from_array(arr){
  1920. return arr.filter(function(x){return !(x === null || x === undefined || x === "")});
  1921. }
  1922. function get_only_particular_key_value(object, path, defaultValue = undefined){
  1923. const isArray = Array.isArray;
  1924. if(object == null || typeof object != 'object') return defaultValue;
  1925. return (isArray(object)) ? object.map(createProcessFunction(path)) : createProcessFunction(path)(object);
  1926. function createProcessFunction(path){
  1927. if(typeof path == 'string') path = path.split('.');
  1928. if(!isArray(path)) path = [path];
  1929. return function(object){
  1930. let index = 0,
  1931. length = path.length;
  1932. while(index < length){
  1933. const key = toString_(path[index++]);
  1934. if(object === undefined){
  1935. return defaultValue;
  1936. }
  1937. // 配列に対する処理
  1938. if(isArray(object)){
  1939. object = object.map(item => item[key]);
  1940. }else{
  1941. object = object[key];
  1942. }
  1943. }
  1944. return (index && index == length) ? object : void 0;
  1945. };
  1946. }
  1947. function toString_(value){
  1948. if(value == null) return '';
  1949. if(typeof value == 'string') return value;
  1950. if(isArray(value)) return value.map(toString) + '';
  1951. let result = value + '';
  1952. return '0' == result && 1 / value == -(1 / 0) ? '-0' : result;
  1953. }
  1954. }
  1955. function sleep(time){
  1956. return new Promise((resolve)=>{
  1957. setTimeout(()=>{return resolve(time)}, time);
  1958. });
  1959. }
  1960. async function expand_shortening_link(urls){
  1961. let isInputArray = true;
  1962. if(typeof urls === 'string'){
  1963. urls = [urls];
  1964. isInputArray = false;
  1965. }
  1966. function isValidURL(url){
  1967. return url.match(/https?:\/\/[\w!\?/\+\-_~=;\.,\*&@#\$%\(\)'\[\]]+/);
  1968. }
  1969. async function expandURL(url){
  1970. if(!isValidURL(url)){
  1971. throw new Error(`Invalid URL: ${url}`);
  1972. }
  1973. const response = await request(new requestObject_url_expand(url));
  1974. return ({
  1975. original: url,
  1976. expanded: response.response
  1977. });
  1978. }
  1979. const results = await Promise.all(urls.map(url => expandURL(url)));
  1980. if(!isInputArray){
  1981. return results[0];
  1982. }
  1983. return results;
  1984. }
  1985. async function addPixivLinksToScriptDataStore(ScreenNames,force = false){
  1986. let promises = ScreenNames.map(async screen_name => {
  1987. if((!((scriptDataStore.Show_me_your_Pixiv[screen_name]?.pixiv_url) === undefined))&&!force)return "Already exists";
  1988. //if((((scriptDataStore.Show_me_your_Pixiv[screen_name]?.Create_date || 0) + 604800000) <= new Date().getTime()) || force){
  1989. if(force){
  1990. let userEntitiesData = await getTweetData(screen_name,"user");
  1991. userEntitiesData = userEntitiesData.legacy?.entities || userEntitiesData.entities;
  1992. const end_stat = await find_pixiv_link(extractUrls(userEntitiesData));
  1993. if(end_stat == "Too Many Requests"){
  1994. console.log("API limit.");
  1995. }else if(!end_stat || end_stat?.match(/(?:users\/|member.php\?id=)(11|9949830|15241365)(\/|$)/)){
  1996. scriptDataStore.Show_me_your_Pixiv[screen_name] = {"pixiv_url": null,"Create_date": new Date().getTime()};
  1997. return `${screen_name}: Pixivリンクなし`;
  1998. }else{
  1999. scriptDataStore.Show_me_your_Pixiv[screen_name] = {"pixiv_url": end_stat.replace(/^https?/,'https'),"Create_date": new Date().getTime()};
  2000. return `${screen_name}: ${end_stat}`;
  2001. }
  2002. }else{
  2003. return "Not yet time";
  2004. }
  2005. });
  2006. const results = await Promise.allSettled(promises);
  2007. results.forEach(result => {
  2008. if(result.status === 'fulfilled'){
  2009. //debug_log(`${result.value}`);
  2010. }else{
  2011. console.error(`Failure: ${result.reason}`);
  2012. }
  2013. });
  2014. localStorage.setItem('user_pixvi_link_collection', JSON.stringify(scriptDataStore.Show_me_your_Pixiv));
  2015. return "finished!";
  2016. function extractUrls(entities){
  2017. let urls = [];
  2018. if (entities.description && entities.description.urls){
  2019. entities.description.urls.forEach(urlObj => {
  2020. urls.push(urlObj.expanded_url || urlObj.url);
  2021. });
  2022. }
  2023. if (entities.url && entities.url.urls){
  2024. entities.url.urls.forEach(urlObj => {
  2025. urls.push(urlObj.expanded_url || urlObj.url);
  2026. });
  2027. }
  2028. return urls;
  2029. }
  2030. }
  2031. function getPixivUrlWithScreenName(screenName){
  2032. let pixivUrl = scriptDataStore.Show_me_your_Pixiv[screenName]?.pixiv_url;
  2033. if(pixivUrl){
  2034. return pixivUrl;
  2035. }else{
  2036. pixivUrl = scriptDataStore.Show_me_your_Pixiv_dataBase[screenName];
  2037. if(Array.isArray(pixivUrl)){
  2038. return `https://www.pixiv.net/users/${pixivUrl[0]}`;
  2039. }else if(pixivUrl){
  2040. return `https://www.pixiv.net/users/${pixivUrl}`;
  2041. }else{
  2042. return null;
  2043. }
  2044. }
  2045. }
  2046. async function find_pixiv_link(urls){
  2047. const Pixiv_url_regex = /^https?:\/\/(((www|touch)\.)?pixiv\.(net\/([a-z]{2}\/)?((member(_illust)?\.php\?id\=|(users|u)\/)[0-9]*)|me\/.*))/;
  2048. const Fanbox_url_regex = /^https?:\/\/(www\.pixiv\.net\/fanbox\/creator\/[0-9]*|(.*\.)?fanbox\.cc\/?(@.*)?)/;
  2049. return new Promise(async function(resolve){
  2050. let tmp_urls = urls;
  2051. let Pixiv_url;
  2052. if(tmp_urls.length > 0){
  2053. Pixiv_url = await find_pixiv_link_from_profile_urls(tmp_urls);
  2054. if(Pixiv_url === undefined || Pixiv_url === null || Pixiv_url === false){
  2055. tmp_urls = get_only_particular_key_value((await expand_shortening_link(tmp_urls)),"expanded",[]);
  2056. Pixiv_url = await find_pixiv_link_from_profile_urls(tmp_urls);
  2057. return resolve(Pixiv_url);
  2058. }else{
  2059. return resolve(Pixiv_url);
  2060. }
  2061. }
  2062. return resolve(null);
  2063. });
  2064. async function find_pixiv_link_from_profile_urls(urls_in_profile){
  2065. return new Promise(async function(resolve,reject){
  2066. let tmp_pixiv_url;
  2067. tmp_pixiv_url = findMatch_from_array(urls_in_profile,Pixiv_url_regex,true);
  2068. if (tmp_pixiv_url !== undefined) return resolve(tmp_pixiv_url);
  2069. if(findMatch_from_array(urls_in_profile,Fanbox_url_regex) !== undefined){
  2070. tmp_pixiv_url = await when_fanbox(findMatch_from_array(urls_in_profile,Fanbox_url_regex,true));
  2071. if(Pixiv_url_regex.test(tmp_pixiv_url)){
  2072. return resolve(tmp_pixiv_url);
  2073. }
  2074. }else{
  2075. let get_url_promise_list = [];
  2076. urls_in_profile.forEach(target=>{
  2077. switch(true){
  2078. case /^https?:\/\/sketch\.pixiv\.net\//.test(target):
  2079. get_url_promise_list.push(new Promise(
  2080. async function(resolve,reject){
  2081. try{
  2082. return resolve(await when_pixiv_sketch(target));
  2083. }catch(error){
  2084. return reject(error);
  2085. }
  2086. }
  2087. ));
  2088. break;
  2089. case /^https?:\/\/((fantia\.jp\/(fanclubs\/[0-9])?.*)|(.*\.booth\.pm)|(.*linktr\.ee)|(.*profcard\.info)|(.*lit\.link)|(potofu\.me)|(.*\.carrd\.co)|(.*\.tumblr\.com$)|(twpf\.jp)|(ci\-en\.dlsite\.com\/creator\/[0-9]*))\/?/.test(target):
  2090. get_url_promise_list.push(new Promise(
  2091. async function(resolve,reject){
  2092. try{
  2093. return resolve(await when_general(target));
  2094. }catch(error){
  2095. return reject(error);
  2096. }
  2097. }
  2098. ));
  2099. break;
  2100. case /^https?:\/\/.*\.creatorlink\.net(\/.*)?/.test(target):
  2101. get_url_promise_list.push(new Promise(
  2102. async function(resolve,reject){
  2103. try{
  2104. return resolve(await when_general(`${target.match(/^https?:\/\/.*\.creatorlink\.net/)[0]}\/Contact`));
  2105. }catch(error){
  2106. return reject(error);
  2107. }
  2108. }
  2109. ));
  2110. break;
  2111. case /^https?:\/\/skeb\.jp\/\@.*/.test(target):
  2112. get_url_promise_list.push(new Promise(
  2113. async function(resolve,reject){
  2114. try{
  2115. return resolve(await when_skeb(target.replace(/^https?:\/\/skeb\.jp\/\@/,'')));
  2116. }catch(error){
  2117. return reject(error);
  2118. }
  2119. }
  2120. ));
  2121. break;
  2122. default:
  2123. break;
  2124. }
  2125. });
  2126. if(get_url_promise_list.length > 0){
  2127. await Promise.any(get_url_promise_list).then((value) => {tmp_pixiv_url = value}).catch(() => {tmp_pixiv_url = undefined});
  2128. if(!Pixiv_url_regex.test(tmp_pixiv_url)) return resolve(undefined);
  2129. return resolve(tmp_pixiv_url.replace(/^https?/,'https').replace(/(\/|\\)$/,''));
  2130. }
  2131. }
  2132. return resolve(null);
  2133. function when_general(target_url){
  2134. return new Promise(async function(resolve,reject){
  2135. const response_data = await request(new requestObject(target_url.replace(/^https?/,"https")));
  2136. console.log({url:target_url.replace(/^https?/,"https"), response:response_data})
  2137. let response_data_urls = response_data.response.split(/\"|\<|\>/).filter(function(data_str){return data_str.match(/^https?:(\/\/(((www|touch)\.)?pixiv\.(net\/([a-z]{2}\/)?((member(_illust)?\.php\?id\=|(users|u|fanbox\/creator)\/)[0-9].*)|me\/.*))|.*\.fanbox\.cc\/?)$/)});
  2138. if(response_data_urls.find(function(element){return element.match(Pixiv_url_regex)}) !== undefined){
  2139. return resolve(response_data_urls.find(function(element){return element.match(Pixiv_url_regex)}));
  2140. }else if(response_data_urls.find(function(element){return element.match(Fanbox_url_regex)}) !== undefined){
  2141. return resolve(await when_fanbox(response_data_urls.find(function(element){return element.match(Fanbox_url_regex)})));
  2142. }else{
  2143. return reject(undefined);
  2144. }
  2145. });
  2146. }
  2147. function when_skeb(target){
  2148. return new Promise(async function(resolve,reject){
  2149. const response_data = await request(new requestObject_skeb(`https://skeb.jp/api/users/${target}`,`https://skeb.jp/@${target}`));
  2150. //console.log({url:`https://skeb.jp/api/users/${target}`,skeb_url: `https://skeb.jp/@${target}`,response_data: response_data})
  2151. let User_id = response_data.response.pixiv_id;
  2152. if(User_id){
  2153. return resolve("https://www.pixiv.net/users/" + User_id);
  2154. }else{
  2155. return reject(undefined);
  2156. }
  2157. });
  2158. }
  2159. function when_pixiv_sketch(target_url){
  2160. return new Promise(async function(resolve,reject){
  2161. const response_data = await request(new requestObject(target_url,"GET","","",true));
  2162. let User_id = response_data.response.split(',').filter(function(data_str){return data_str.match(/\\"pixiv_user_id\\":\\"[\d]+\\"/)});
  2163. if(User_id){
  2164. return resolve("https://www.pixiv.net/users/" + User_id[0].match(/[\d]+/)[0]);
  2165. }else{
  2166. return reject(undefined);
  2167. }
  2168. });
  2169. }
  2170. function when_fanbox(fanbox_url){
  2171. return new Promise(async function(resolve,reject){
  2172. if(fanbox_url.match(/^https?:\/\/www\.pixiv\.net\/fanbox\/creator\/[0-9]*/)){
  2173. return resolve(fanbox_url.replace('fanbox/creator', 'users'));
  2174. }else{
  2175. const fanbox_name = fanbox_url.match(/https?:\/\/(?:www\.)?(?:fanbox\.cc\/@([^\/]+)|([^\.]+)\.fanbox\.cc)/);
  2176. const fanbox_response = await request(new requestObject_fanbox(`https://api.fanbox.cc/creator.get?creatorId=${fanbox_name[1] || fanbox_name[2]}`,`https://${fanbox_name[1] || fanbox_name[2]}.fanbox.cc`));
  2177. if(fanbox_response.status == "404") return reject(undefined);
  2178. tmp_pixiv_url = findMatch_from_array(fanbox_response.response.body.profileLinks,Pixiv_url_regex,true);
  2179. if(tmp_pixiv_url !== undefined){
  2180. return resolve(tmp_pixiv_url);
  2181. }else{
  2182. return resolve(`https://www.pixiv.net/users/${fanbox_response.response.body.user.userId}`);
  2183. }
  2184. }
  2185. });
  2186. }
  2187. });
  2188. }
  2189. }
  2190. function round_half_up(original_value,where_round_off,decimal_place = 0,unit_str = ""){
  2191. //四捨五入関数。
  2192. /*
  2193. original_valu: 元の値
  2194. where_round_off: どこで四捨五入するか(0.1, 1, 10, 100, 1000など)
  2195. decimal_place: 小数点以下を何桁にするか(1, 2, 3, 4, 5など)
  2196. unit_str: 単位を末尾につける(千,万など)
  2197. */
  2198. if(Number(original_value)>=Number(where_round_off)){
  2199. let tmp_value;
  2200. tmp_value = Math.round(Number(original_value) / Number(where_round_off) * Math.pow(10,Number(decimal_place))) / Math.pow(10,Number(decimal_place));
  2201. if(unit_str == ""){
  2202. return tmp_value;
  2203. }else{
  2204. return `${tmp_value}${unit_str}`
  2205. }
  2206. }else{
  2207. return original_value;
  2208. }
  2209. }
  2210. function findMatch_from_array(arr, regex, returnMatchedSubstring = false){
  2211. const matchedElement = arr.find(element => regex.test(element));
  2212. if(matchedElement && returnMatchedSubstring){
  2213. const matchResult = matchedElement.match(regex);
  2214. return matchResult ? matchResult[0] : undefined;
  2215. }
  2216. return matchedElement;
  2217. }
  2218. function fetchAndProcessTwitterApi(method,id = undefined,forceFetch = false){
  2219. let response;
  2220. return new Promise(async (resolve, reject) => {
  2221. try{
  2222. switch(method){
  2223. case 'TL':
  2224. case 'forYou':
  2225. await getTL();
  2226. break;
  2227. case 'userMedia':
  2228. await getUserMedia();
  2229. break;
  2230. case 'mediaSearch':
  2231. await getMediaSerch();
  2232. break;
  2233. case 'graphQL':
  2234. if((fetchedTweets[id]?.API_type === "graphQL") && !(forceFetch === true))return resolve(fetchedTweets[id]);
  2235. await graphQL();
  2236. break;
  2237. case 'user':
  2238. await getUser();
  2239. break;
  2240. case 'user_1_1':
  2241. //await getUser1_1();
  2242. //break;
  2243. case '1_1':
  2244. //await get1_1();
  2245. console.log('twitter API v1.1でツイートのデータを収集することはできなくなりました。');
  2246. break;
  2247. default:
  2248. console.warn("なにか間違ってないか?")
  2249. return reject("something wrong.");
  2250. }
  2251. return resolve("OK!");
  2252. }catch(error){
  2253. console.error(error);
  2254. console.error(response);
  2255. throw new Error(`Failed to fetch API data.\nmethod: ${method}\nid: ${id}`);
  2256. }
  2257. });
  2258. async function getMediaSerch(){
  2259. let url = 'https://x.com/i/api/graphql/Aj1nGkALq99Xg3XI0OZBtw/SearchTimeline'
  2260. let variables = {
  2261. "rawQuery": encodeURIComponent(id),
  2262. "count": 50,
  2263. "querySource": "recent_search_click",
  2264. "product": "Media"
  2265. }
  2266. if(scriptDataStore.Show_all_Medias[(await encodeBase64(id))]?.cursor){
  2267. variables.cursor = scriptDataStore.Show_all_Medias[(await encodeBase64(id))]?.cursor;
  2268. }
  2269. response = await request(new requestObject_twitter_get_search_media(url,variables));
  2270. if(!response.status === "200")throw new Error(`Failed to fetch`);
  2271. const instructions = response.response.data.search_by_raw_query.search_timeline.timeline.instructions;
  2272. const TimelineAddEntries = instructions.find(element => element.type === 'TimelineAddEntries');
  2273. if(!scriptDataStore.Show_all_Medias[(await encodeBase64(id))])scriptDataStore.Show_all_Medias[(await encodeBase64(id))] = {};
  2274. scriptDataStore.Show_all_Medias[(await encodeBase64(id))].cursor = TimelineAddEntries.entries.find(element => element.entryId.match(/^cursor-bottom/)).content.value;
  2275. const tweetData = instructions[0]?.moduleItems || TimelineAddEntries.entries;
  2276. processgraphQL(tweetData);
  2277. return "OK";
  2278. }
  2279. async function getUserMedia(){
  2280. let userData = await getTweetData(id,"user")
  2281. let userID = userData.rest_id || userData.id_str;
  2282. let url = 'https://x.com/i/api/graphql/dQAjBEzWOl_hQwnc1sLUsA/UserMedia'
  2283. let variables = {
  2284. "userId": `${userID}`,
  2285. "count": 200,
  2286. "includePromotedContent": false,
  2287. "withClientEventToken": false,
  2288. "withBirdwatchNotes": false,
  2289. "withVoice": true,
  2290. "withV2Timeline": true
  2291. };
  2292. if(scriptDataStore.Show_all_Medias[id]?.cursor){
  2293. variables.cursor = scriptDataStore.Show_all_Medias[id]?.cursor;
  2294. }
  2295. response = await request(new requestObject_twitter_get_user_media(url,variables));
  2296. if(!response.status === "200")throw new Error(`Failed to fetch`);
  2297. const instructions = response.response.data.user.result.timeline_v2.timeline.instructions;
  2298. const TimelineAddEntries = instructions.find(element => element.type === 'TimelineAddEntries');
  2299. if(!scriptDataStore.Show_all_Medias[id])scriptDataStore.Show_all_Medias[id] = {};
  2300. scriptDataStore.Show_all_Medias[id].cursor = TimelineAddEntries.entries.find(element => element.entryId.match(/^cursor-bottom/)).content.value;
  2301. const tweetData = instructions[0]?.moduleItems || TimelineAddEntries.entries[0]?.content?.items;
  2302. processgraphQL(tweetData);
  2303. return "OK";
  2304. }
  2305. async function getTL(){
  2306. let requestObject;
  2307. if(method == 'TL'){
  2308. requestObject = new requestObject_twitter_time_line();
  2309. }else{
  2310. requestObject = new requestObject_twitter_time_line_forYou();
  2311. }
  2312. response = await request(requestObject);
  2313. if(!response.status === "200")throw new Error(`Failed to fetch`);
  2314. processgraphQL(response.response.data.home.home_timeline_urt.instructions[0].entries);
  2315. }
  2316. async function graphQL(){
  2317. response = await request(new requestObject_twitter_api_graphql(id));
  2318. if(!response.status === "200")throw new Error(`Failed to fetch`);
  2319. processgraphQL(response.response.data.threaded_conversation_with_injections_v2.instructions[0].entries);
  2320. }
  2321. async function getUser(){
  2322. if(fetchedTweetsUserDataByUserName[id]?.API_type === "graphQL" && !forceFetch)return;
  2323. response = await request(new requestObject_twitter_get_user_by_screenname(id));
  2324. if(!response.status === "200")throw new Error(`Failed to fetch`);
  2325. const userData = response.response.data.user.result;
  2326. fetchedTweetsUserData[userData.rest_id] = {...userData,"API_type": "graphQL"};
  2327. fetchedTweetsUserDataByUserName[userData.legacy.screen_name] = fetchedTweetsUserData[userData.rest_id];
  2328. return "OK";
  2329. }
  2330. async function getUser1_1(){
  2331. if(fetchedTweetsUserDataByUserName[id] && !forceFetch)return;
  2332. response = await request(new requestObject_twitter_get_user_by_screenname_1_1(id));
  2333. if(!response.status === "200")throw new Error(`Failed to fetch`);
  2334. if(response.response.status && !(fetchedTweets[response.response.status?.id_str]?.API_type === "graphQL")){
  2335. fetchedTweets[response.response.status.id_str] = {...response.response.status,"API_type": "1_1"};
  2336. response.response.status = fetchedTweets[response.response.status.id_str];
  2337. }
  2338. fetchedTweetsUserData[response.response.id_str] = {...response.response,"API_type": "1_1"};
  2339. fetchedTweetsUserDataByUserName[response.response.screen_name] = fetchedTweetsUserData[response.response.id_str];
  2340. return "OK";
  2341. }
  2342. async function get1_1(){
  2343. const idsToFetch = forceFetch ? id : id.filter(singleId => !(fetchedTweets[singleId]?.API_type === "graphQL"));
  2344. if(idsToFetch.length === 0) return;
  2345. response = await request(new requestObject_twitter_api_v1_1(idsToFetch.join(",")));
  2346. if(!response.status === "200")throw new Error(`Failed to fetch`);
  2347. response.response.forEach((tweetData)=>{
  2348. if(tweetData.quoted_status){
  2349. let quoted = tweetData.quoted_status;
  2350. if(!(fetchedTweetsUserData[quoted.user.id_str]?.API_type === "graphQL")){
  2351. fetchedTweetsUserData[quoted.user.id_str] = {...quoted.user,"API_type": "1_1"};
  2352. fetchedTweetsUserDataByUserName[quoted.user.screen_name] = fetchedTweetsUserData[quoted.user.id_str];
  2353. }
  2354. quoted.user = fetchedTweetsUserData[quoted.user.id_str];
  2355. if(!(fetchedTweets[quoted.id_str]?.API_type === "graphQL")){
  2356. fetchedTweets[quoted.id_str] = {...quoted,"API_type": "1_1"};
  2357. }
  2358. tweetData.quoted_status = fetchedTweets[quoted.id_str];
  2359. }
  2360. if(!(fetchedTweetsUserData[tweetData.user.id_str]?.API_type === "graphQL")){
  2361. fetchedTweetsUserData[tweetData.user.id_str] = {...tweetData.user,"API_type": "1_1"};
  2362. fetchedTweetsUserDataByUserName[tweetData.user.screen_name] = fetchedTweetsUserData[tweetData.user.id_str];
  2363. }
  2364. tweetData.user = fetchedTweetsUserData[tweetData.user.id_str];
  2365. fetchedTweets[tweetData.id_str] = {...tweetData,"API_type": "1_1"};
  2366. });
  2367. return "OK";
  2368. }
  2369. function processgraphQL(entries){
  2370. if(!entries)return null;
  2371. entries.forEach(entry=>{
  2372. const tmpData = entry.content?.itemContent?.tweet_results || entry.item?.itemContent?.tweet_results;
  2373. let tweetData = tmpData?.result?.tweet || tmpData?.result;
  2374. if(tweetData?.tombstone)return;
  2375. if(!tweetData)return;
  2376. try{
  2377. if(tweetData.quoted_status_result){
  2378. if(Object.keys(tweetData.quoted_status_result).length !== 0){
  2379. let quoted = tweetData.quoted_status_result.result?.tweet || tweetData.quoted_status_result.tweet || tweetData.quoted_status_result?.result;
  2380. fetchedTweetsUserData[quoted.core.user_results.result.rest_id] = {...quoted.core.user_results.result,"API_type": "graphQL"};
  2381. fetchedTweetsUserDataByUserName[quoted.core.user_results.result.legacy.screen_name] = fetchedTweetsUserData[quoted.core.user_results.result.rest_id];
  2382. quoted.core.user_results.result = fetchedTweetsUserData[quoted.core.user_results.result.rest_id];
  2383. fetchedTweets[quoted.rest_id] = {...quoted,"API_type": "graphQL"};
  2384. tweetData.quoted_status_result.result = fetchedTweets[quoted.rest_id];
  2385. }
  2386. }
  2387. fetchedTweetsUserData[tweetData.core.user_results.result.rest_id] = {...tweetData.core.user_results.result,"API_type": "graphQL"};
  2388. fetchedTweetsUserDataByUserName[tweetData.core.user_results.result.legacy.screen_name] = fetchedTweetsUserData[tweetData.core.user_results.result.rest_id];
  2389. tweetData.core.user_results.result = fetchedTweetsUserData[tweetData.core.user_results.result.rest_id];
  2390. fetchedTweets[tweetData.rest_id] = {...tweetData,"API_type": "graphQL"};
  2391. }catch(error){
  2392. console.error
  2393. console.error({error: `processgraphQL error.\ndetails: ${error}`,apiResponse:tweetData});
  2394. }
  2395. });
  2396. return "OK";
  2397. }
  2398. }
  2399. async function getTweetData(id, method = 'graphQL', forceFetch = false){
  2400. const dataStore = method === 'user' || method === 'user_1_1' ? fetchedTweetsUserDataByUserName : fetchedTweets;
  2401. let ids;
  2402. if(typeof id === 'string'){
  2403. if(dataStore[id] && !forceFetch){
  2404. if((method === "user" || method === "graphQL") && dataStore[id].API_type !== '1_1'){
  2405. return dataStore[id];
  2406. }
  2407. }
  2408. ids = [id];
  2409. }else if(Array.isArray(id)){
  2410. if(!forceFetch && id.every(singleId => dataStore[singleId] && !(dataStore[singleId].API_type === '1_1' && method !== 'graphQL')))return id.map(singleId => (dataStore[singleId]));
  2411. ids = id;
  2412. }else{
  2413. throw new Error("Invalid ID type.");
  2414. }
  2415. if(method == "1_1") ids = [ids];
  2416. let promises = ids.map(singleId => fetchAndProcessTwitterApi(method, singleId, forceFetch));
  2417. await Promise.all(promises);
  2418.  
  2419. if(typeof id === 'string'){
  2420. if(dataStore[id]){
  2421. return dataStore[id];
  2422. }else{
  2423. throw new Error("Failed to fetch tweet data for ID: " + id);
  2424. }
  2425. }else if(Array.isArray(id)){
  2426. if(id.every(singleId => dataStore[singleId])){
  2427. return id.map(singleId => dataStore[singleId]);
  2428. }else{
  2429. throw new Error("Failed to fetch tweet data for some IDs.");
  2430. }
  2431. }
  2432. }
  2433. function waitForTweetData(id, method = "graphQL", retry = 30, span = 100){
  2434. let dataStore = method === 'user' || method === 'user_1_1' ? fetchedTweetsUserDataByUserName : fetchedTweets;
  2435. if(typeof id === 'string'){
  2436. if(dataStore[id]?.API_type === method)return dataStore[id];
  2437. id = [id];
  2438. }else if(Array.isArray(id)){
  2439. if(id.every(singleId => dataStore[singleId]?.API_type === method))return id.map(singleId => dataStore[singleId]);
  2440. }else{
  2441. throw new Error(`Invalid ID type: ${typeof id}. Expected string or array.`);
  2442. }
  2443. return new Promise((resolve, reject) => {
  2444. const MAX_RETRY_COUNT = retry;
  2445. let retry_counter = 0;
  2446. let set_interval_id = setInterval(isThereTweetData, span);
  2447. async function isThereTweetData(){
  2448. retry_counter++;
  2449. if(dataStore[id]){
  2450. clearInterval(set_interval_id);
  2451. return resolve(dataStore[id]);
  2452. }
  2453. if(retry_counter > MAX_RETRY_COUNT){
  2454. await getTweetData(id, method);
  2455. if(typeof id === 'string'){
  2456. if(dataStore[id]){
  2457. return resolve(dataStore[id]);
  2458. }else{
  2459. return reject("Max retry count reached");
  2460. }
  2461. }else if(Array.isArray(id)){
  2462. if(id.every(singleId => dataStore[singleId])){
  2463. return resolve(id.map(singleId => dataStore[singleId]));
  2464. }else{
  2465. return reject("Max retry count reached");
  2466. }
  2467. }
  2468. }
  2469. }
  2470. });
  2471. }
  2472. async function getFileSize(url){
  2473. const response = await request(new requestObject_binary_head(url));
  2474. if(response.responseHeaders.match(/content-length: ?(\d+)/)){
  2475. return response.responseHeaders.match(/content-length: ?(\d+)/)[1];
  2476. }else{
  2477. return null;
  2478. }
  2479. }
  2480. function decodeHtml(html){
  2481. var txt = document.createElement("textarea");
  2482. txt.innerHTML = html;
  2483. return txt.value;
  2484. }
  2485. async function encodeBase64(data){
  2486. const blob = new Blob([data], {type: 'text/plain; charset=UTF-8'});
  2487. const reader = new FileReader();
  2488. return new Promise((resolve, reject) => {
  2489. reader.onloadend = () => resolve(reader.result.split(',')[1]);
  2490. reader.onerror = reject;
  2491. reader.readAsDataURL(blob);
  2492. });
  2493. }
  2494. function decodeBase64(encodedData){
  2495. const bytes = atob(encodedData).split('').map(char => char.charCodeAt(0));
  2496. return new TextDecoder().decode(new Uint8Array(bytes));
  2497. }
  2498. function getDarkMode(){
  2499. try{
  2500. const color = ["#FFFFFF","#15202B","#000000"];
  2501. const themeColor = document.querySelector('head > meta[name="theme-color"]').content;
  2502. const darkModeNum = color.indexOf(themeColor);
  2503. return darkModeNum || null;
  2504. }catch{
  2505. return 0;
  2506. }
  2507. }
  2508. function openIndexedDB(dbName, storeName){
  2509. return new Promise((resolve, reject) => {
  2510. let request = indexedDB.open(dbName);
  2511.  
  2512. request.onerror = (event) => {
  2513. reject("Database error: " + event.target.errorCode);
  2514. };
  2515.  
  2516. request.onsuccess = (event) => {
  2517. let db = event.target.result;
  2518. if(db.objectStoreNames.contains(storeName)){
  2519. resolve(db);
  2520. }else{
  2521. db.close();
  2522. let newVersion = db.version + 1;
  2523. let versionRequest = indexedDB.open(dbName, newVersion);
  2524. versionRequest.onupgradeneeded = (event) => {
  2525. db = event.target.result;
  2526. db.createObjectStore(storeName, { keyPath: 'id' });
  2527. };
  2528. versionRequest.onsuccess = (event) => {
  2529. resolve(event.target.result);
  2530. };
  2531. versionRequest.onerror = (event) => {
  2532. reject("Database error: " + event.target.errorCode);
  2533. };
  2534. }
  2535. };
  2536.  
  2537. request.onupgradeneeded = (event) => {
  2538. let db = event.target.result;
  2539. db.createObjectStore(storeName, { keyPath: 'id' });
  2540. };
  2541. });
  2542. }
  2543.  
  2544. function saveToIndexedDB(dbName, storeName, data, id = 522){
  2545. return new Promise(async (resolve, reject) => {
  2546. try{
  2547. let db = await openIndexedDB(dbName, storeName);
  2548. let transaction = db.transaction(storeName, 'readwrite');
  2549. let store = transaction.objectStore(storeName);
  2550. let putRequest = store.put({ id: id, data: data });
  2551.  
  2552. putRequest.onsuccess = () => {
  2553. resolve("Data saved successfully.");
  2554. };
  2555.  
  2556. putRequest.onerror = (event) => {
  2557. reject("Data save error: " + event.target.errorCode);
  2558. };
  2559. }catch(error){
  2560. reject(error);
  2561. }
  2562. });
  2563. }
  2564.  
  2565. function getFromIndexedDB(dbName, storeName, id = 522){
  2566. return new Promise(async (resolve, reject) => {
  2567. try{
  2568. let db = await openIndexedDB(dbName, storeName);
  2569. let transaction = db.transaction(storeName, 'readonly');
  2570. let store = transaction.objectStore(storeName);
  2571. let getRequest = store.get(id);
  2572.  
  2573. getRequest.onsuccess = (event) => {
  2574. if(event.target.result){
  2575. resolve(event.target.result.data);
  2576. }else{
  2577. resolve(null);
  2578. }
  2579. };
  2580.  
  2581. getRequest.onerror = (event) => {
  2582. reject("Data fetch error: " + event.target.errorCode);
  2583. };
  2584. }catch(error){
  2585. reject(error);
  2586. }
  2587. });
  2588. }
  2589. function openSettings(){
  2590. if(document.querySelector('.settingWindowContainer'))return;
  2591. let container = document.createElement('div');
  2592. container.style.position = 'fixed';
  2593. container.style.width = '70vw';
  2594. container.style.height = '80vh';
  2595. container.style.backgroundColor = 'rgba(220, 200, 200, 0.9)';
  2596. container.style.zIndex = '9999';
  2597. container.style.display = 'flex';
  2598. container.style.maxHeight = '80vh';
  2599. container.style.top = '50%'; // 画面の上から50%の位置
  2600. container.style.left = '50%'; // 画面の左から50%の位置
  2601. container.style.transform = 'translate(-50%, -50%)'; // 要素の中心を基準に位置を調整
  2602. container.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.5)';
  2603. container.style.flexDirection = 'column';
  2604. container.className = `settingWindowContainer`
  2605. document.body.appendChild(container);
  2606. let pages = {};
  2607. let nav = document.createElement('div');
  2608. nav.style.position = 'static';
  2609. nav.style.top = '0';
  2610. nav.style.left = '0';
  2611. nav.style.width = '100%';
  2612. nav.style.zIndex = '2';
  2613. nav.style.display = 'flex';
  2614. nav.style.flexWrap = 'wrap';
  2615. container.appendChild(nav);
  2616. let contentWrapper = document.createElement('div');
  2617. contentWrapper.style.flexGrow = '1';
  2618. contentWrapper.style.position = 'relative';
  2619. contentWrapper.style.flexDirection = 'column';
  2620. contentWrapper.style.display = 'flex';
  2621. contentWrapper.style.overflowY = 'auto';
  2622. container.appendChild(contentWrapper);
  2623. let fotter = document.createElement('div');
  2624. fotter.style.position = 'static';
  2625. fotter.style.width = '100%';
  2626. fotter.style.zIndex = '2';
  2627. fotter.style.display = 'flex';
  2628. fotter.style.flexWrap = 'wrap';
  2629. fotter.style.left = '1em';
  2630. fotter.style.bottom = '1em';
  2631. container.appendChild(fotter);
  2632. let saveAllButton = document.createElement('button');
  2633. saveAllButton.textContent = 'Save All';
  2634. saveAllButton.addEventListener('click', saveAll);
  2635. fotter.appendChild(saveAllButton);
  2636. let cancelButton = document.createElement('button');
  2637. cancelButton.textContent = 'キャンセル';
  2638. cancelButton.addEventListener('click', () => {
  2639. container.remove();
  2640. document.head.querySelectorAll('style.settingCss').forEach(s=>{
  2641. s.remove();
  2642. });
  2643. });
  2644. fotter.appendChild(cancelButton);
  2645.  
  2646. /////////////////////////////////////////////
  2647. /*
  2648. function createPageTemplate(){
  2649. const pageName = "hogehoge";
  2650. const textData = env_Text[pageName];
  2651. const thisStoredSettings = storedSettings[pageName];
  2652. let thisScriptSettings = script_settings[pageName];
  2653. const settingEntries = [
  2654. {id: 'settings1', name: "設定1", type: 'radioButton', option: ['option1', 'option2', 'option3']},
  2655. {id: 'settings2', name: "設定2", type: 'textBox'},
  2656. {id: 'settings3', name: "設定3", type: 'toggleSwitch'},
  2657. ];
  2658. let contents = createPage(pageName,pageName,textData.functionName);
  2659. let mainContent = contents.main;
  2660. mainContent.innerHTML = `
  2661. <div class="${pageName}MainContents">
  2662. </div>
  2663. `;
  2664. settingEntries.map(setting => {
  2665. let settingElement = createSettingsElement(setting);
  2666. let container = document.createElement('div');
  2667. container.className = 'setting-item';
  2668. let label = document.createElement('span');
  2669. label.className = 'item_name';
  2670. label.textContent = setting.name;
  2671. container.appendChild(label);
  2672. container.appendChild(settingElement);
  2673. mainContent.firstChild.appendChild(container);
  2674. });
  2675. let style = document.createElement('style');
  2676. style.className = `settingCss ${pageName}`
  2677. style.textContent = `
  2678.  
  2679. `;
  2680. document.head.appendChild(style);
  2681. pages[pageName].saveFunction = save;
  2682. function save(){
  2683. console.log(pageName)
  2684. }
  2685. }
  2686. */
  2687. function createquickShareTweetLinkSettings(){
  2688. const pageName = "quickShareTweetLink";
  2689. const textData = env_Text[pageName];
  2690. const thisStoredSettings = storedSettings[pageName];
  2691. let thisScriptSettings = script_settings[pageName];
  2692. const settingEntries = [
  2693. {id: 'domain', name: textData.selectDomain, type: 'dropdown', option: ['x.com', 'twitter.com', 'vxtwitter.com', textData.useOther]},
  2694. {id: 'otherDomain', name: textData.other, type: 'textBox'},
  2695. ];
  2696. let contents = createPage(pageName,pageName,textData.functionName);
  2697. let mainContent = contents.main;
  2698. mainContent.innerHTML = `
  2699. <div class="${pageName}MainContents">
  2700. </div>
  2701. `;
  2702. settingEntries.map(setting => {
  2703. let settingElement = createSettingsElement(setting,thisStoredSettings[setting.id]);
  2704. let container = document.createElement('div');
  2705. container.className = 'setting-item';
  2706. let label = document.createElement('span');
  2707. label.className = `${setting.id}`;
  2708. label.textContent = setting.name;
  2709. container.appendChild(label);
  2710. container.appendChild(settingElement);
  2711. mainContent.appendChild(container);
  2712. });
  2713. let style = document.createElement('style');
  2714. style.className = `settingCss ${pageName}`
  2715. style.textContent = `
  2716.  
  2717. `;
  2718. document.head.appendChild(style);
  2719. pages[pageName].saveFunction = save;
  2720. function save(){
  2721. const settingsToSave = {};
  2722. settingEntries.forEach(setting => {
  2723. let value, selectedRadio;
  2724. switch(setting.type){
  2725. case 'radioButton':
  2726. selectedRadio = document.querySelector(`input[name="${setting.id}"]:checked`);
  2727. value = selectedRadio ? parseInt(selectedRadio.value, 10) : null;
  2728. break;
  2729.  
  2730. case 'textBox':
  2731. value = document.getElementById(setting.id).value;
  2732. break;
  2733.  
  2734. case 'toggleSwitch':
  2735. value = document.querySelector(`[id="${setting.id}"] input[type="checkbox"]`).checked;
  2736. break;
  2737.  
  2738. case 'dropdown':
  2739. value = parseInt(document.getElementById(setting.id).value, 10);
  2740. break;
  2741. }
  2742. settingsToSave[setting.id] = value;
  2743. });
  2744. localStorage.setItem(pageName, JSON.stringify(settingsToSave));
  2745. script_settings[pageName] = settingsToSave;
  2746. }
  2747.  
  2748. }
  2749. function creategGeneralPage(){
  2750. const pageName = "general"
  2751. let thisScript_settings = script_settings.Make_Twitter_little_useful;
  2752. let contents = createPage(pageName,env_Text.general,env_Text.general);
  2753. let mainContent = contents.main;
  2754. let header = contents.header;
  2755. const features = [
  2756. {id: 'Note_Tweet_expander', name: env_Text.Note_Tweet_expander.functionName},
  2757. {id: 'Engagement_Restorer', name: env_Text.Engagement_Restorer.functionName},
  2758. {id: 'Hello_tweet_where_are_you_from', name: env_Text.Hello_tweet_where_are_you_from.functionName},
  2759. {id: 'Show_me_your_Pixiv', name: env_Text.Show_me_your_Pixiv.functionName},
  2760. {id: 'sneakilyFavorite', name: env_Text.sneakilyFavorite.functionName},
  2761. {id: 'showFollowers', name: env_Text.showFollowers.functionName},
  2762. {id: 'hideAnalytics', name: env_Text.hideAnalytics.functionName},
  2763. {id: 'webhook_brings_tweets_to_discord', name: env_Text.webhook_brings_tweets_to_discord.functionName},
  2764. {id: 'quickShareTweetLink', name: env_Text.quickShareTweetLink.functionName},
  2765. {id: 'Show_all_Medias', name: env_Text.Show_all_Medias.functionName},
  2766. //{id: 'returnFavorites', name: env_Text.returnFavorites.functionName},
  2767. ];
  2768. let featureListContent = features.map(feature => {
  2769. return `
  2770. <div class="featureItem">
  2771. <label class="switch">
  2772. <input type="checkbox" id="${feature.id}" class="featureToggle" ${thisScript_settings.featuresToggle[feature.id] === true ? 'checked' : ''}>
  2773. <span class="slider round"></span>
  2774. </label>
  2775. <span>${feature.name}</span>
  2776. </div>
  2777. `;
  2778. }).join('');
  2779. mainContent.innerHTML = `
  2780. <div class="${pageName}MainContents">
  2781. <span class="item_name">${env_Text.featureToggle}</span>
  2782. <div class="featureList">
  2783. ${featureListContent}
  2784. </div>
  2785. <span class="item_name">Language</span>
  2786. <select id="languageSelect">
  2787. ${Object.keys(Text).map(lang_ => `<option value="${lang_}" ${lang_ === thisScript_settings.lang ? 'selected' : ''}>${lang_}</option>`).join('')}
  2788. </select>
  2789. </div>
  2790. `;
  2791. let style = document.createElement('style');
  2792. style.className = `settingCss ${pageName}`
  2793. style.textContent = `
  2794. .switch {
  2795. position: relative;
  2796. display: inline-block;
  2797. width: 2.58em;
  2798. height: 1em;
  2799. }
  2800. .switch input {
  2801. opacity: 0;
  2802. width: 0;
  2803. height: 0;
  2804. }
  2805. /* スライダーのスタイル */
  2806. .slider {
  2807. position: absolute;
  2808. cursor: pointer;
  2809. top: 0;
  2810. left: 0;
  2811. right: 0;
  2812. bottom: 0;
  2813. background-color: #ccc;
  2814. transition: .4s;
  2815. border-radius: 1em; /* 高さに合わせてborder-radiusを変更 */
  2816. }
  2817.  
  2818. .slider:before {
  2819. position: absolute;
  2820. content: "";
  2821. height: 0.8em; /* 高さを0.8emに変更 */
  2822. width: 0.8em; /* 幅を0.8emに変更 */
  2823. left: 0.1em; /* 位置を調整 */
  2824. bottom: 0.1em; /* 位置を調整 */
  2825. background-color: white;
  2826. transition: .4s;
  2827. border-radius: 50%;
  2828. }
  2829.  
  2830. input:checked + .slider {
  2831. background-color: #2196F3;
  2832. }
  2833.  
  2834. input:checked + .slider:before {
  2835. transform: translateX(1.6em); /* スライダーの移動距離を調整 */
  2836. }
  2837. `;
  2838. document.head.appendChild(style);
  2839. pages[pageName].saveFunction = save;
  2840. function save(){
  2841. features.forEach(feature => {
  2842. const checkbox = document.getElementById(feature.id);
  2843. thisScript_settings.featuresToggle[feature.id] = checkbox.checked;
  2844. });
  2845. thisScript_settings.lang = document.getElementById('languageSelect').value;
  2846. localStorage.setItem('Make_Twitter_little_useful', JSON.stringify(thisScript_settings));
  2847. storedSettings[pageName] = JSON.parse(localStorage.getItem('webhook_brings_tweets_to_discord') || '{}');
  2848. env_Text = Text[thisScript_settings.lang];
  2849. }
  2850. }
  2851. function createShowMeYourPixiv(){
  2852. const pageName = "Show_me_your_Pixiv";
  2853. const textData = env_Text[pageName];
  2854. const thisStoredSettings = storedSettings[pageName];
  2855. let thisScriptSettings = script_settings[pageName];
  2856. const settingEntries = [
  2857. {id: 'showMeYourPixivCollectionMethod', name: textData.collectionMethod, type: 'radioButton', option: [textData.everywhere, textData.atProfile, textData.never]},
  2858. //{id: 'settings2', name: "設定2", type: 'textBox'},
  2859. //{id: 'settings3', name: "設定3", type: 'toggleSwitch'},
  2860. ];
  2861. let contents = createPage(pageName,pageName,textData.functionName);
  2862. let mainContent = contents.main;
  2863. mainContent.innerHTML = `
  2864. <div class="${pageName}MainContents">
  2865. </div>
  2866. `;
  2867. settingEntries.map(setting => {
  2868. let settingElement = createSettingsElement(setting,thisStoredSettings[setting.id]);
  2869. let container = document.createElement('div');
  2870. container.className = 'setting-item';
  2871. let label = document.createElement('span');
  2872. label.className = `${setting.id}`;
  2873. label.textContent = setting.name;
  2874. container.appendChild(label);
  2875. container.appendChild(settingElement);
  2876. mainContent.appendChild(container);
  2877. });
  2878. const addPixivUrlListContainer = document.createElement('div');
  2879. const addPixivUrlListTitle = document.createElement('span');
  2880. addPixivUrlListTitle.innerText = textData.addPixivUrlListTitle;
  2881. const addPixivUrlListButton = document.createElement('button');
  2882. addPixivUrlListButton.textContent = "download";
  2883. addPixivUrlListButton.addEventListener('click',async () =>{
  2884. await addPixivUrlList();
  2885. });
  2886. addPixivUrlListContainer.appendChild(addPixivUrlListTitle);
  2887. addPixivUrlListContainer.appendChild(addPixivUrlListButton);
  2888. mainContent.querySelector('.setting-item').appendChild(addPixivUrlListContainer);
  2889. document.head.appendChild(style);
  2890. pages[pageName].saveFunction = save;
  2891. function save(){
  2892. const settingsToSave = {};
  2893. settingEntries.forEach(setting => {
  2894. let value,selectedRadio;
  2895. switch(setting.type){
  2896. case 'radioButton':
  2897. selectedRadio = document.querySelector(`input[name="${setting.id}"]:checked`);
  2898. value = selectedRadio ? parseInt(selectedRadio.value, 10) : null;
  2899. break;
  2900.  
  2901. case 'textBox':
  2902. value = document.getElementById(setting.id).value;
  2903. break;
  2904.  
  2905. case 'toggleSwitch':
  2906. value = document.querySelector(`[id="${setting.id}"] input[type="checkbox"]`).checked;
  2907. break;
  2908. }
  2909. settingsToSave[setting.id] = value;
  2910. });
  2911. localStorage.setItem(pageName, JSON.stringify(settingsToSave));
  2912. script_settings['Show_me_your_Pixiv'] = settingsToSave;
  2913. }
  2914. async function addPixivUrlList(){
  2915. const downloadData = JSON.parse((await request(new requestObject('https://dl.dropboxusercontent.com/s/stvehlbre5gir6xtaxgz8/screenName2PixivID.json?rlkey=0vqz5kb333fehmcd1xtftj9b5'))).response);
  2916. if(!(Object.keys(downloadData).length > 100)){
  2917. customAlert(textData.faildAddPixivUrlList);
  2918. return;
  2919. }
  2920. scriptDataStore.Show_me_your_Pixiv_dataBase = downloadData;
  2921. await saveToIndexedDB('Show_me_your_Pixiv','pixiv_link_collection_dataBase',downloadData);
  2922. customAlert(textData.successAddPixivUrlList);
  2923. }
  2924. }
  2925. function createShowAllMediasSettingPage(){
  2926. const pageName = "Show_all_Medias";
  2927. const textData = env_Text[pageName];
  2928. const thisStoredSettings = storedSettings[pageName];
  2929. let thisScriptSettings = script_settings[pageName];
  2930. const settingEntries = [
  2931. {id: 'displayMethod', name: textData.displayMethod, type: 'radioButton', option: [textData.expand ,textData.likeTweet]},
  2932. {id: 'removeBlur', name: textData.removeBlur, type: 'toggleSwitch'},
  2933. {id: 'onlyRemoveBlur', name: textData.onlyRemoveBlur, type: 'toggleSwitch'},
  2934. //{id: 'settings2', name: "設定2", type: 'textBox'},
  2935. //{id: 'settings3', name: "設定3", type: 'toggleSwitch'},
  2936. ];
  2937. let contents = createPage(pageName,pageName,textData.functionName);
  2938. let mainContent = contents.main;
  2939. mainContent.innerHTML = `
  2940. <div class="${pageName}MainContents">
  2941. </div>
  2942. `;
  2943. settingEntries.map(setting => {
  2944. let settingElement = createSettingsElement(setting,thisStoredSettings[setting.id]);
  2945. let container = document.createElement('div');
  2946. container.className = 'setting-item';
  2947. let label = document.createElement('span');
  2948. label.className = `${setting.id}`;
  2949. label.textContent = setting.name;
  2950. container.appendChild(label);
  2951. container.appendChild(settingElement);
  2952. mainContent.appendChild(container);
  2953. });
  2954. /*
  2955. let style = document.createElement('style');
  2956. style.className = `settingCss ${pageName}`
  2957. style.textContent = `
  2958.  
  2959. `;
  2960. */
  2961.  
  2962. document.head.appendChild(style);
  2963. pages[pageName].saveFunction = save;
  2964. function save(){
  2965. const settingsToSave = {};
  2966. settingEntries.forEach(setting => {
  2967. let value,selectedRadio;
  2968. switch(setting.type){
  2969. case 'radioButton':
  2970. selectedRadio = document.querySelector(`input[name="${setting.id}"]:checked`);
  2971. value = selectedRadio ? parseInt(selectedRadio.value, 10) : null;
  2972. break;
  2973.  
  2974. case 'textBox':
  2975. value = document.getElementById(setting.id).value;
  2976. break;
  2977.  
  2978. case 'toggleSwitch':
  2979. value = document.querySelector(`[id="${setting.id}"] input[type="checkbox"]`).checked;
  2980. break;
  2981. }
  2982. settingsToSave[setting.id] = value;
  2983. });
  2984. localStorage.setItem(pageName, JSON.stringify(settingsToSave));
  2985. script_settings['Show_all_Medias'] = settingsToSave
  2986. }
  2987. }
  2988. function createAdvancedPage(){
  2989. const pageName = "Advanced";
  2990. const textData = env_Text[pageName];
  2991. let contents = createPage(pageName);
  2992. contents.header.innerHTML = `<span style="font-size: 2em; font-weight: 700">${textData.functionName}</span>`;
  2993. contents.footer.innerHTML = "";
  2994. let mainContent = contents.main;
  2995. mainContent.innerHTML = `
  2996. <div class="${pageName}MainContents">
  2997. <span class="item_name">${textData.ExportSettings}</span>
  2998. <input type="button" id="exportButton" style="display: none;">
  2999. <label for="exportButton" class="customFileIO"">${textData.Export}</label><br>
  3000. <span class="item_name">${textData.ImportSettings}</span>
  3001. <input type="file" id="importFile" accept=".json" style="display: none;">
  3002. <label for="importFile" class="customFileIO">${textData.Inport}</label><br>
  3003. </div>
  3004. `;
  3005. let style = document.createElement('style');
  3006. style.className = `settingCss ${pageName}`
  3007. style.textContent = `
  3008. .customFileIO {
  3009. display: inline-block;
  3010. padding: 0.5em 1em;
  3011. background-color: rgb(30, 39, 50);
  3012. color: white;
  3013. cursor: pointer;
  3014. border-radius: 5px;
  3015. height: 1em;
  3016. line-height: 1em;
  3017. }
  3018. `;
  3019. document.head.appendChild(style);
  3020. const exportSettings = () => {
  3021. const data = {
  3022. Make_Twitter_little_useful_script_SettingsData: storedSettings,
  3023. };
  3024. const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(data));
  3025. const downloadAnchorNode = document.createElement('a');
  3026. downloadAnchorNode.setAttribute("href", dataStr);
  3027. downloadAnchorNode.setAttribute("download", "scriptSettings.json");
  3028. document.body.appendChild(downloadAnchorNode);
  3029. downloadAnchorNode.click();
  3030. downloadAnchorNode.remove();
  3031. };
  3032. const importSettings = (event) => {
  3033. const file = event.target.files[0];
  3034. if(file){
  3035. const reader = new FileReader();
  3036. reader.onload = function(e) {
  3037. try{
  3038. const importedData = JSON.parse(e.target.result);
  3039. if(!importedData || !importedData.Make_Twitter_little_useful_script_SettingsData){
  3040. throw new Error("Invalid data format");
  3041. }
  3042. const importedSettings = importedData.Make_Twitter_little_useful_script_SettingsData;
  3043. for(let key in importedSettings){
  3044. localStorage.setItem(key, JSON.stringify(importedSettings[key]));
  3045. }
  3046. location.reload();
  3047. }catch(error){
  3048. console.error(error);
  3049. customAlert(textData.invalidJson);
  3050. }
  3051. };
  3052. reader.readAsText(file);
  3053. }
  3054. };
  3055. document.getElementById("exportButton").addEventListener("click", exportSettings);
  3056. document.getElementById("importFile").addEventListener("change", importSettings);
  3057. pages[pageName].saveFunction = save;
  3058. function save(){
  3059. return;
  3060. }
  3061. }
  3062. function createDebugPage(){
  3063. const pageName = "ForDebug";
  3064. const textData = env_Text[pageName];
  3065. let contents = createPage(pageName);
  3066. contents.header.innerHTML = `<span style="font-size: 2em; font-weight: 700">${textData.functionName}</span>`;
  3067. contents.footer.innerHTML = "";
  3068. let mainContent = contents.main;
  3069. let mainContainer = document.createElement("div");
  3070. mainContainer.className = `${pageName}MainContents`
  3071. mainContainer.style.display = "flex";
  3072. mainContainer.style.flexDirection = "column";
  3073.  
  3074. mainContainer.appendChild(makeInputMenu('showTweetData', true));
  3075. mainContainer.appendChild(makeInputMenu('showUserByScreenNameData', true));
  3076. mainContainer.appendChild(makeInputMenu('showUserByUserID', false));
  3077. mainContainer.appendChild(makeExpandUrlMenu());
  3078.  
  3079. mainContent.appendChild(mainContainer);
  3080. pages[pageName].saveFunction = save;
  3081.  
  3082. function makeInputMenu(name){
  3083. let container = document.createElement('div');
  3084. container.className = `${name}`;
  3085. container.style.display = 'flex';
  3086. container.style.flexDirection = 'column';
  3087.  
  3088. let title = document.createElement('span');
  3089. title.className = "item_name";
  3090. title.innerText = name;
  3091. container.appendChild(title);
  3092.  
  3093. let inputElement = document.createElement('input');
  3094. inputElement.className = `${name}InputElement`;
  3095. inputElement.type = 'text';
  3096. inputElement.style.width = 'fit-content'
  3097. container.appendChild(inputElement);
  3098. let selectContainer = document.createElement('div');
  3099. let useMethod, isForce;
  3100. if(name !== 'showUserByUserID'){
  3101. useMethod = document.createElement('select');
  3102. useMethod.className = `${name}SelectElement`;
  3103. ['graphQL','1_1'].forEach(value => {
  3104. const option = document.createElement('option');
  3105. option.value = value;
  3106. option.textContent = value;
  3107. useMethod.appendChild(option);
  3108. });
  3109. selectContainer.appendChild(useMethod);
  3110.  
  3111. isForce = document.createElement('select');
  3112. isForce.className = `${name}SelectElement`;
  3113. ['false','true'].forEach(value => {
  3114. const option = document.createElement('option');
  3115. option.value = value;
  3116. option.textContent = value;
  3117. isForce.appendChild(option);
  3118. });
  3119. selectContainer.appendChild(isForce);
  3120. }
  3121. const button = document.createElement('button');
  3122. button.className = `${name}ButtonElement`;
  3123. button.textContent = textData.get;
  3124. button.addEventListener('click', whenButtonClicked);
  3125. selectContainer.appendChild(button);
  3126. container.appendChild(selectContainer);
  3127.  
  3128. return container;
  3129. async function whenButtonClicked(){
  3130. const inputValue = inputElement?.value;
  3131. const selectedMethod = useMethod?.value;
  3132. const forceValue = isForce?.value;
  3133. switch(name){
  3134. case('showTweetData'):
  3135. console.log(await getTweetData(inputValue,selectedMethod,(forceValue === "true"? true :false)));
  3136. break;
  3137. case('showUserByScreenNameData'):
  3138. console.log(await getTweetData(inputValue,(selectedMethod === "1_1" ? "user_1_1" : "user"),(forceValue === "true"? true :false)));
  3139. break;
  3140. case('showUserByUserID'):
  3141. console.log(fetchedTweetsUserData[inputValue]);
  3142. break;
  3143. }
  3144. }
  3145. }
  3146.  
  3147. function makeExpandUrlMenu(){
  3148. let container = document.createElement('div');
  3149. container.className = 'expandUrlContainer';
  3150. container.style.display = 'flex';
  3151. container.style.flexDirection = 'column';
  3152.  
  3153. let title = document.createElement('span');
  3154. title.className = "item_name";
  3155. title.innerText = 'Expand Short URL';
  3156. container.appendChild(title);
  3157.  
  3158. let inputContainer = document.createElement('div');
  3159. inputContainer.style.display = 'flex';
  3160. inputContainer.style.alignItems = 'center';
  3161.  
  3162. let inputElement = document.createElement('input');
  3163. inputElement.className = 'expandUrlInputElement';
  3164. inputElement.type = 'text';
  3165. inputElement.style.width = 'fit-content';
  3166. inputContainer.appendChild(inputElement);
  3167.  
  3168. const button = document.createElement('button');
  3169. button.className = 'expandUrlButtonElement';
  3170. button.textContent = textData.get;
  3171. button.style.width = 'fit-content'; // スタイルの追加
  3172. button.addEventListener('click', async () => {
  3173. const inputValue = inputElement.value;
  3174. const expandedUrl = await expand_shortening_link(inputValue);
  3175. console.log(expandedUrl);
  3176. let expandedUrlElement = document.querySelector('.expandedUrlElement');
  3177. if(!expandedUrlElement){
  3178. expandedUrlElement = document.createElement('div');
  3179. expandedUrlElement.className = 'expandedUrlElement';
  3180. container.appendChild(expandedUrlElement);
  3181. }
  3182. expandedUrlElement.innerText = expandedUrl.expanded;
  3183. });
  3184. inputContainer.appendChild(button);
  3185. container.appendChild(inputContainer);
  3186. return container;
  3187. }
  3188. function save() {
  3189. return;
  3190. }
  3191. }
  3192.  
  3193.  
  3194. function createStylePage(){
  3195. const pageName = "style";
  3196. const textData = env_Text[pageName];
  3197. const thisStoredSettings = storedSettings[pageName];
  3198. let thisScriptSettings = script_settings[pageName];
  3199. let contents = createPage(pageName,pageName,textData.functionName);
  3200. let mainContent = contents.main;
  3201. mainContent.innerHTML = `
  3202. <div class="${pageName}MainContents">
  3203. <span class="item_name">hogehoge</span>
  3204. </div>
  3205. `;
  3206. document.head.querySelectorAll(`style.settingCss.${pageName}`).forEach(e=>e.remove());
  3207. let style = document.createElement('style');
  3208. style.className = `settingCss ${pageName}`
  3209. style.textContent = `
  3210.  
  3211. `;
  3212. document.head.appendChild(style);
  3213. pages[pageName].saveFunction = save;
  3214. function save(){
  3215. console.log(pageName)
  3216. }
  3217. }
  3218. function createWebhook_brings_tweets_to_discordPage(){
  3219. const pageName = "webhook_brings_tweets_to_discord"
  3220. const textData = env_Text.webhook_brings_tweets_to_discord;
  3221. let contents = createPage(pageName,"webhook",textData.functionName);
  3222. let mainContent = contents.main;
  3223. const thisStoredSettings = storedSettings[pageName];
  3224. let thisScriptSettings = script_settings[pageName];
  3225. mainContent.innerHTML = `
  3226. <div class="${pageName}MainContents webhook-container" style="">
  3227. <span class="item_name">Webhooks</span>
  3228. <div id="webhooks" style="">
  3229. <!-- ここにWebhookの設定行が動的に追加されます -->
  3230. </div>
  3231. <div class="addWebhookButton">
  3232. <button id="addWebhook">+</button>
  3233. </div>
  3234. <div class="defaultWebhook">
  3235. <span class="item_name">${textData.default}Webhook</span><br>
  3236. <select id="defaultWebhook"></select>
  3237. </div>
  3238. <div class="displayMethod">
  3239. <span class="item_name">${textData.display_method}</span><br>
  3240. <select id="displayMethod">
  3241. <option value="method1">${textData.display_everywhere}</option>
  3242. <option value="method2">${textData.tweet_details_only}</option>
  3243. </select>
  3244. </div>
  3245. <div class="sendLangage">
  3246. <span class="item_name">${textData.language}</span><br>
  3247. <select id="sendLanguageSelect">
  3248. ${Object.keys(Text).map(lang_ => `<option value="${lang_}" ${lang_ === script_settings.webhook_brings_tweets_to_discord.lang ? 'selected' : ''}>${lang_}</option>`).join('')}
  3249. </select>
  3250. </div>
  3251. <div class="downloadVideo">
  3252. <span class="item_name">${textData.Video_Download_Option}</span><br>
  3253. <input type="radio" id="downloadYes" name="downloadOption" value="true" ${thisStoredSettings.downloadVideo === true ? 'checked' : ''}>
  3254. <label for="downloadYes">Yes</label>
  3255. <input type="radio" id="downloadNo" name="downloadOption" value="false" ${thisStoredSettings.downloadVideo === false ? 'checked' : ''}>
  3256. <label for="downloadNo">No</label>
  3257. </div>
  3258. <br>
  3259. </div>
  3260. `;
  3261. let style = document.createElement('style');
  3262. style.className = `settingCss ${pageName}`
  3263. style.textContent = `
  3264. .webhook-container {
  3265. display: flex;
  3266. flex-direction: column;
  3267. }
  3268.  
  3269. .webhook-row {
  3270. display: flex;
  3271. align-items: center; /* 子要素を中央揃えにする */
  3272. flex-wrap: wrap; /* 必要に応じて折り返す */
  3273. }
  3274.  
  3275. .webhook-name,.webhook-url{
  3276. margin-right: 5px; /* 余白を追加 */
  3277. }
  3278.  
  3279. `;
  3280. document.head.appendChild(style);
  3281. document.getElementById('addWebhook').addEventListener('click', () => {
  3282. addWebhookRow();
  3283. });
  3284. function addWebhookRow(name = '', url = ''){
  3285. let row = document.createElement('div');
  3286. row.className = 'webhook-row';
  3287. row.draggable = true;
  3288. row.innerHTML = `
  3289. <div style="display:flex;border-bottom: 1px solid;flex-wrap: wrap;">
  3290. <div class="WebhookName">
  3291. <label>Name:</label>
  3292. <input type="text" class="webhook-name" value="${name}">
  3293. </div>
  3294. <div class=">WebhookUrl">
  3295. <label>URL:</label>
  3296. <input type="text" class="webhook-url" value="${url}">
  3297. </div>
  3298. <div class="removeWebhookButton">
  3299. <button class="removeWebhook">X</button>
  3300. </div>
  3301. </div>
  3302. `;
  3303. row.querySelector('.removeWebhook').addEventListener('click', () => {
  3304. row.remove();
  3305. updateDefaultWebhookOptions();
  3306. });
  3307. row.addEventListener('dragstart', handleDragStart);
  3308. row.addEventListener('dragover', handleDragOver);
  3309. row.addEventListener('drop', handleDrop);
  3310. row.addEventListener('dragend', handleDragEnd);
  3311. document.getElementById('webhooks').appendChild(row);
  3312. }
  3313. function handleDragStart(e){
  3314. e.dataTransfer.effectAllowed = 'move';
  3315. e.dataTransfer.setData('text/html', e.target.outerHTML);
  3316. this.classList.add('dragging');
  3317. }
  3318. function handleDragOver(e){
  3319. e.preventDefault();
  3320. e.dataTransfer.dropEffect = 'move';
  3321. this.classList.add('drag-over');
  3322. }
  3323. function handleDrop(e){
  3324. e.stopPropagation();
  3325. e.preventDefault();
  3326. if(this.classList.contains('dragging')){
  3327. return;
  3328. }
  3329. let draggingElem = document.querySelector('.dragging');
  3330. this.insertAdjacentHTML('beforebegin', e.dataTransfer.getData('text/html'));
  3331. this.previousSibling.querySelector('.removeWebhook').addEventListener('click', () => {
  3332. this.previousSibling.remove();
  3333. updateDefaultWebhookOptions();
  3334. });
  3335. this.previousSibling.addEventListener('dragstart', handleDragStart);
  3336. this.previousSibling.addEventListener('dragover', handleDragOver);
  3337. this.previousSibling.addEventListener('drop', handleDrop);
  3338. this.previousSibling.addEventListener('dragend', handleDragEnd);
  3339. draggingElem.remove();
  3340. updateDefaultWebhookOptions();
  3341. }
  3342. function handleDragEnd(){
  3343. this.classList.remove('dragging');
  3344. document.querySelectorAll('.webhook-row').forEach(row => row.classList.remove('drag-over'));
  3345. }
  3346. //console.log(thisStoredSettings.data)
  3347. function updateDefaultWebhookOptions(){
  3348. let select = document.getElementById('defaultWebhook');
  3349. select.innerHTML = '';
  3350. let webhookElements = document.getElementById('webhooks').children;
  3351. for(let elem of webhookElements){
  3352. let name = elem.querySelector('.webhook-name').value;
  3353. if(name){
  3354. let option = document.createElement('option');
  3355. option.value = name;
  3356. option.textContent = name;
  3357. select.appendChild(option);
  3358. }
  3359. }
  3360. }
  3361. if(thisStoredSettings.data){
  3362. for(let item of thisStoredSettings.data){
  3363. let decodedUrl = 'https://discord.com/api/webhooks/' + decodeBase64(item.value);
  3364. addWebhookRow(item.name, decodedUrl);
  3365. let option = document.createElement('option');
  3366. option.value = item.name;
  3367. option.textContent = item.name;
  3368. document.getElementById('defaultWebhook').appendChild(option);
  3369. }
  3370. }
  3371. pages[pageName].saveFunction = save;
  3372. async function save(){
  3373. let data = [];
  3374. let names = [];
  3375. let hasDuplicate = false;
  3376. let hasInvalidWebhook = false;
  3377. let webhookElements = document.getElementById('webhooks').children;
  3378.  
  3379. for(let elem of webhookElements){
  3380. let name = elem.querySelector('.webhook-name').value;
  3381. let url = elem.querySelector('.webhook-url').value;
  3382.  
  3383. if(name && url){
  3384. if(!/^https:\/\/discord\.com\/api\/webhooks\/[\w-]+\/[\w-]+$/.test(url)){
  3385. elem.querySelector('.webhook-url').style.backgroundColor = 'red';
  3386. hasInvalidWebhook = true; // 無効なWebhookを検出
  3387. continue;
  3388. }else{
  3389. elem.querySelector('.webhook-url').style.backgroundColor = '';
  3390. }
  3391.  
  3392. // URLをBase64エンコード
  3393. let encodedUrl = await encodeBase64(url.replace('https://discord.com/api/webhooks/', ''));
  3394. if(names.includes(name)){
  3395. hasDuplicate = true;
  3396. elem.querySelector('.webhook-name').style.backgroundColor = 'red';
  3397. }else{
  3398. names.push(name);
  3399. elem.querySelector('.webhook-name').style.backgroundColor = '';
  3400. data.push({ name, value: encodedUrl });
  3401. }
  3402. }
  3403. }
  3404. if(hasDuplicate){
  3405. customAlert(textData.when_webhook_name_duplicate);
  3406. return;
  3407. }
  3408. if(hasInvalidWebhook){
  3409. customAlert(textData.when_webhook_url_invalid);
  3410. return;
  3411. }
  3412. // 設定をJSON形式で保存
  3413. let selectedLanguage = document.getElementById('sendLanguageSelect').value;
  3414. let settings = {
  3415. data: data,
  3416. downloadVideo: getDownloadOption(),
  3417. defaultWebhook: document.getElementById('defaultWebhook').value,
  3418. displayMethod: document.getElementById('displayMethod').value,
  3419. lang: selectedLanguage
  3420. };
  3421. localStorage.setItem('webhook_brings_tweets_to_discord', JSON.stringify(settings));
  3422.  
  3423. // 保存した設定を再度読み込む
  3424. storedSettings[pageName] = settings;
  3425.  
  3426. script_settings[pageName] = {
  3427. "displayMethod": storedSettings[pageName].displayMethod || 'method1',
  3428. "lang": storedSettings[pageName].lang || GetCookie("lang") || 'en',
  3429. "defaultWebhook": storedSettings[pageName].defaultWebhook,
  3430. "webHooks": (function(data){
  3431. let webhooks = {};
  3432. if(data && Array.isArray(data)){
  3433. data.forEach(item => {
  3434. if(item.name && item.value){
  3435. webhooks[item.name] = item.value;
  3436. }
  3437. });
  3438. }
  3439. return webhooks;
  3440. })(storedSettings[pageName].data)
  3441. };
  3442. updateDefaultWebhookOptions();
  3443. document.querySelectorAll('.quickDimg').forEach((target)=>{target.remove()});
  3444. main(true);
  3445. function getDownloadOption(){
  3446. const radioButtons = document.querySelectorAll('.downloadVideo input[name="downloadOption"]');
  3447. for(let i = 0; i < radioButtons.length; i++){
  3448. if(radioButtons[i].checked){
  3449. return radioButtons[i].value === "true";
  3450. }
  3451. }
  3452. return null;
  3453. }
  3454. };
  3455. }
  3456.  
  3457. function createPage(name,buttonText = undefined,headerText = undefined){
  3458. let page = document.createElement('div');
  3459. page.style.position = 'relative';
  3460. page.style.display = 'flex';
  3461. page.style.flexDirection = 'column';
  3462. page.style.flexGrow = '0';
  3463. page.style.flexShrink = '1';
  3464. page.style.top = '0';
  3465. page.style.left = '0';
  3466. page.style.width = 'auto';
  3467. page.style.height = 'auto';
  3468. page.style.zIndex = '-1';
  3469. page.style.overflowY = 'auto';
  3470. page.style.border = '1px solid black';
  3471. page.style.padding = "0.5em";
  3472. page.className = `${name} settingChildWindow`;
  3473. page.setAttribute('settingName', name);
  3474. let header = document.createElement('div');
  3475. header.className = 'pageHeader';
  3476. header.innerHTML = `<span style="font-size: 2em; font-weight: 700">${headerText || name} ${env_Text.settings}</span>`;
  3477. header.style.color = 'black';
  3478. page.appendChild(header);
  3479. let contentContainer = document.createElement('div');
  3480. contentContainer.className = 'pageContent';
  3481. contentContainer.style.display = 'flex';
  3482. contentContainer.style.flexDirection = 'column';
  3483. contentContainer.style.overflowY = 'auto';
  3484. contentContainer.style.color = 'black';
  3485. page.appendChild(contentContainer);
  3486. let footer = document.createElement('div');
  3487. footer.className = 'pageFooter';
  3488. footer.style.marginTop = "1em";
  3489. let saveButton = document.createElement('button');
  3490. saveButton.textContent = 'Save';
  3491. saveButton.addEventListener('click', function(){
  3492. if(pages[name] && typeof pages[name].saveFunction === 'function'){
  3493. pages[name].saveFunction();
  3494. }
  3495. });
  3496. footer.appendChild(saveButton);
  3497. page.appendChild(footer);
  3498. pages[name] = {
  3499. "page": page,
  3500. "saveFunction": function(){}
  3501. };
  3502. contentWrapper.appendChild(page);
  3503. makeChangePageButton(name,buttonText)
  3504. return {"all": page,"header": header,"main": contentContainer,"footer": footer};
  3505. }
  3506. function createSettingsElement(setting, storedValue){
  3507. let element, checkbox, slider;
  3508. switch(setting.type){
  3509. case 'radioButton':
  3510. element = document.createElement('div');
  3511. setting.option.forEach((opt, index) => {
  3512. let label = document.createElement('label');
  3513. let radioButton = document.createElement('input');
  3514. radioButton.type = 'radio';
  3515. radioButton.name = setting.id;
  3516. radioButton.value = index;
  3517. if(storedValue === index){
  3518. radioButton.checked = true;
  3519. }
  3520. label.appendChild(radioButton);
  3521. label.appendChild(document.createTextNode(opt));
  3522. element.appendChild(label);
  3523. });
  3524. break;
  3525. case 'textBox':
  3526. element = document.createElement('input');
  3527. element.type = 'text';
  3528. element.id = setting.id;
  3529. element.value = storedValue || '';
  3530. break;
  3531. case 'toggleSwitch':
  3532. element = document.createElement('label');
  3533. element.className = 'switch';
  3534. element.id = setting.id;
  3535. checkbox = document.createElement('input');
  3536. checkbox.type = 'checkbox';
  3537. checkbox.checked = storedValue || false;
  3538. slider = document.createElement('span');
  3539. slider.className = 'slider';
  3540. element.appendChild(checkbox);
  3541. element.appendChild(slider);
  3542. break;
  3543. case 'dropdown':
  3544. element = document.createElement('select');
  3545. element.id = setting.id;
  3546. setting.option.forEach((opt, index) => {
  3547. let option = document.createElement('option');
  3548. option.value = index;
  3549. option.text = opt;
  3550. if(storedValue === index){
  3551. option.selected = true;
  3552. }
  3553. element.appendChild(option);
  3554. });
  3555. break;
  3556. }
  3557. return element;
  3558. }
  3559.  
  3560. function showPage(name){
  3561. for(let key in pages){
  3562. if(key === name){
  3563. pages[key].page.style.zIndex = '1';
  3564. pages[key].page.style.display = 'flex';
  3565. }else{
  3566. pages[key].page.style.zIndex = '-1';
  3567. pages[key].page.style.display = 'none';
  3568. }
  3569. }
  3570. }
  3571. function makeChangePageButton(name,buttonText = undefined){
  3572. if(buttonText === undefined)buttonText = name;
  3573. let homeButton = document.createElement('button');
  3574. homeButton.textContent = buttonText;
  3575. homeButton.addEventListener('click', () => showPage(name));
  3576. nav.appendChild(homeButton);
  3577. }
  3578. async function saveAll(){
  3579. for(let key in pages){
  3580. await pages[key].saveFunction();
  3581. }
  3582. container.remove();
  3583. document.head.querySelectorAll('style.settingCss').forEach(s=>{
  3584. s.remove();
  3585. });
  3586. storedSettings = {
  3587. 'Make_Twitter_little_useful': JSON.parse(localStorage.getItem('Make_Twitter_little_useful') || '{}'),
  3588. 'webhook_brings_tweets_to_discord': JSON.parse(localStorage.getItem('webhook_brings_tweets_to_discord') || '{}'),
  3589. 'Hello_tweet_where_are_you_from': JSON.parse(localStorage.getItem('Hello_tweet_where_are_you_from') || '{}'),
  3590. 'Show_me_your_Pixiv': JSON.parse(localStorage.getItem('Show_me_your_Pixiv') || '{}'),
  3591. 'Note_Tweet_expander': JSON.parse(localStorage.getItem('Note_Tweet_expander') || '{}'),
  3592. 'sneakilyFavorite': JSON.parse(localStorage.getItem('sneakilyFavorite') || '{}'),
  3593. 'Engagement_Restorer': JSON.parse(localStorage.getItem('Engagement_Restorer') || '{}'),
  3594. 'Show_all_Medias': JSON.parse(localStorage.getItem('Show_all_Medias') || '{}'),
  3595. 'quickShareTweetLink': JSON.parse(localStorage.getItem('quickShareTweetLink') || '{}'),
  3596. }
  3597. }
  3598. let style = document.createElement('style');
  3599. style.className = "settingCss"
  3600. style.textContent = `
  3601. .pageHeader, .pageFooter {
  3602. flex-shrink: 0;
  3603. }
  3604. .pageContent {
  3605. flex-grow: 1;
  3606. overflow-y: auto;
  3607. }
  3608. .item_name {
  3609. font-size: 1.5em;
  3610. }
  3611. `;
  3612. document.head.appendChild(style);
  3613. creategGeneralPage();
  3614. createShowAllMediasSettingPage();
  3615. createShowMeYourPixiv();
  3616. createWebhook_brings_tweets_to_discordPage();
  3617. createquickShareTweetLinkSettings();
  3618. createAdvancedPage();
  3619. createDebugPage();
  3620. showPage('general');
  3621. }
  3622. GM_registerMenuCommand('script settings', openSettings);
  3623. function customAlert(message, url){
  3624. let overlay = document.createElement('div');
  3625. overlay.style.position = 'fixed';
  3626. overlay.style.top = '0';
  3627. overlay.style.left = '0';
  3628. overlay.style.width = '100%';
  3629. overlay.style.height = '100%';
  3630. overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  3631. overlay.style.zIndex = '10000';
  3632. let alertBox = document.createElement('div');
  3633. alertBox.style.position = 'absolute';
  3634. alertBox.style.top = '50%';
  3635. alertBox.style.left = '50%';
  3636. alertBox.style.transform = 'translate(-50%, -50%)';
  3637. alertBox.style.padding = '20px';
  3638. alertBox.style.backgroundColor = 'white';
  3639. alertBox.style.border = '1px solid black';
  3640. alertBox.style.zIndex = '10001';
  3641. alertBox.style.maxWidth = '80%'; // ボックスの最大幅を設定してテキストを折り返します
  3642. alertBox.style.whiteSpace = 'pre-wrap'; // 改行と空白を保持します
  3643.  
  3644. let alertMessage = document.createElement('p');
  3645. alertMessage.innerHTML = message.replace(/\n/g, '<br>'); // \nを<br>に置き換えて改行を表示します
  3646. alertMessage.style.color = 'black';
  3647.  
  3648. let closeButton = document.createElement('button');
  3649. closeButton.textContent = env_Text.close;
  3650. alertBox.addEventListener('click', (e) => {
  3651. e.stopPropagation(); // これにより、イベントがoverlayまで伝播しなくなります
  3652. });
  3653. overlay.addEventListener('click', () => {
  3654. document.body.removeChild(overlay);
  3655. });
  3656. closeButton.addEventListener('click', () => {
  3657. document.body.removeChild(overlay);
  3658. });
  3659.  
  3660. alertBox.appendChild(alertMessage);
  3661.  
  3662. // URLが提供された場合、それを表示するa要素を作成します
  3663. if(url){
  3664. let urlElement = document.createElement('a');
  3665. urlElement.href = url;
  3666. urlElement.textContent = url;
  3667. urlElement.style.display = 'block';
  3668. urlElement.style.marginTop = '10px';
  3669. urlElement.target = '_blank';
  3670. urlElement.rel = 'noopener';
  3671. alertBox.appendChild(urlElement);
  3672. }
  3673. alertBox.appendChild(closeButton);
  3674. overlay.appendChild(alertBox);
  3675. document.body.appendChild(overlay);
  3676. }
  3677.  
  3678. function request(object, maxRetries = 0, timeout = 60000){
  3679. let retryCount = 0;
  3680. while(retryCount <= maxRetries){
  3681. try{
  3682. return new Promise((resolve, reject) => {
  3683. GM_xmlhttpRequest({
  3684. method: object.method,
  3685. url: object.url,
  3686. headers: object.headers,
  3687. responseType: object.respType,
  3688. data: object.body,
  3689. anonymous: object.anonymous,
  3690. timeout: timeout,
  3691. onload: function(responseDetails){
  3692. return resolve(responseDetails);
  3693. },
  3694. ontimeout: function(responseDetails){
  3695. console.warn(responseDetails);
  3696. return reject(`[request]time out:\nresponse ${responseDetails}`);
  3697. },
  3698. onerror: function(responseDetails){
  3699. console.warn(responseDetails);
  3700. return reject(`[request]error:\nresponse ${responseDetails}`);
  3701. }
  3702. });
  3703. });
  3704. }catch(error){
  3705. retryCount++;
  3706. console.warn(`Retry ${retryCount}: Failed to fetch ${object.url}. Reason: ${error}`);
  3707. if(retryCount === maxRetries){
  3708. throw new Error(`Failed to fetch ${object.url} after ${maxRetries} retries.`);
  3709. }
  3710. }
  3711. }
  3712. }
  3713. /////////////////////////////////////////////////////////////////////
  3714. /////////////////////////////////CTA/////////////////////////////////
  3715. /////////////////////////////////////////////////////////////////////
  3716. let ctaEngagementStore = {};
  3717. async function createTwitterArticle(targetTweetData,tweetId,appendParentNode, noAppend = false,tag = undefined){
  3718. let texts = {};
  3719. texts.ja = {
  3720. "units": "万",
  3721. "roundingScale": 10000,
  3722. "decimalPlaces": 2,
  3723. "retweet": "リツイート",
  3724. "like": "いいね",
  3725. "bookmark": "ブックマーク",
  3726. "doneRetweet": "リツイートしました",
  3727. "doneLike": "いいねしました",
  3728. "doneBookmark": "ブックマークしました",
  3729. "faildRetweet": "リツイートに失敗しました",
  3730. "faildUnRetweet": "リツイートの取り消しに失敗しました",
  3731. "faildLike": "いいねにしっぱいしました",
  3732. "faildUnLike": "いいねの取り消しに失敗しました",
  3733. "faildBookmark": "ブックマークに失敗しました",
  3734. "faildUnBookmark": "ブックマークの取り消しに失敗しました",
  3735. "unRetweet": "リツイートを取り消しました",
  3736. "unLike": "いいねを取り消しました",
  3737. "unBookmark": "ブックマークを取り消しました",
  3738.  
  3739. };
  3740. texts.en = {
  3741. "units": "k",
  3742. "roundingScale": 1000,
  3743. "decimalPlaces": 1,
  3744. "retweet": "Retweet",
  3745. "like": "Like",
  3746. "bookmark": "Bookmark",
  3747. "doneRetweet": "Retweeted",
  3748. "doneLike": "Liked",
  3749. "doneBookmark": "Bookmarked",
  3750. "faildRetweet": "Failed to Retweet",
  3751. "faildUnRetweet": "Failed to Undo Retweet",
  3752. "faildLike": "Failed to Like",
  3753. "faildUnLike": "Failed to Undo Like",
  3754. "faildBookmark": "Failed to Bookmark",
  3755. "faildUnBookmark": "Failed to Undo Bookmark",
  3756. "unRetweet": "Retweet Undone",
  3757. "unLike": "Like Undone",
  3758. "unBookmark": "Bookmark Undone",
  3759. };
  3760. let textData = GetCookie("lang") === "ja" ? texts.ja : texts.en;
  3761. let night_mode = getDarkMode() || 0;
  3762. let colors = {
  3763. "fontColor": ['rgb(15, 20, 25)','rgb(247, 249, 249)','rgb(231, 233, 234)'][night_mode],
  3764. "fontColorDark": ['rgb(83, 100, 113)','rgb(139, 152, 165)','rgb(113, 118, 123)'][night_mode],
  3765. "backgroundColor": ['rgba(255,255,255,1.00)','rgb(21, 32, 43)','rgba(0, 0, 0, 1.00)'][night_mode],
  3766. "borderBottomColor": ['rgb(239, 243, 244)','rgb(56, 68, 77)','rgb(47, 51, 54)'][night_mode],
  3767. }
  3768. let tweetData = await tweetDataProsess(targetTweetData,tweetId);
  3769. let quotedTweetData = targetTweetData.quoted_status_result?.result || targetTweetData.quoted_status || null;
  3770. if(quotedTweetData){
  3771. quotedTweetData = await tweetDataProsess(quotedTweetData);
  3772. }
  3773. let tweetNode = document.createElement('div');
  3774. let headerNode = createHeaderNode();
  3775. let avatarNode = createAvatarNode();
  3776. let authorNode = createAuthorNode();
  3777. let textNode = createTextNode();
  3778. let mediaNode = createMediaNode();
  3779. let quotedNode = createQuotedNode();
  3780. let engagementsNode = createEngagementNode();
  3781. tweetNode.innerHTML = `
  3782. <div data-testid="cellInnerDiv" style="width: 100%;" ${tag? `cta-Id=${tag}`: ''}>
  3783. <div class="cta-base cta-display-block cta-outline-style-none" style="border-bottom-color: ${colors.borderBottomColor}; border-bottom-width: 1px;">
  3784. <div class="cta-base">
  3785. <article aria-labelledby="" role="article" tabindex="0" class="cta-base cta-flex-direction-row cta-overflow-hidden cta-padding-right cta-padding-left cta-transition-duration cta-transition-property cta-outline-style-none cta-cursor-pointer" data-testid="tweet" ${tag? `cta-Id=${tag}`: ''}>
  3786. <div class="cta-base cta-flex-direction-column cta-flex-grow-1 cta-flex-shrink-1">
  3787. <div class="cta-base cta-flex-grow-1 cta-flex-shrink-1 cta-outline-style-none" cta-id="header">
  3788. <!--ヘッダー-->
  3789. <div class="cta-base cta-flex-direction-row" cta-id="avatar-place">
  3790. <!--アバター-->
  3791. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-justify-content-center cta-padding-bottom" cta-id="main">
  3792. <!--ユーザー名とか-->
  3793. <!--ツイートのテキスト-->
  3794. <!--メディア-->
  3795. <!--引用-->
  3796. <!--エンゲージメントとか-->
  3797. </div>
  3798. </div>
  3799. </div>
  3800. </div>
  3801. </article>
  3802. </div>
  3803. </div>
  3804. </div>
  3805. `.replace(/\t|\n/g, '');
  3806. if(headerNode)tweetNode.querySelector('[cta-id="header"]').insertBefore(headerNode.firstChild, tweetNode.querySelector('[cta-id="header"]').firstChild);
  3807. if(avatarNode)tweetNode.querySelector('[cta-id="avatar-place"]').insertBefore(avatarNode.firstChild, tweetNode.querySelector('[cta-id="avatar-place"]').firstChild);
  3808. if(authorNode)tweetNode.querySelector('[cta-id="main"]').appendChild(authorNode.firstChild);
  3809. if(textNode)tweetNode.querySelector('[cta-id="main"]').appendChild(textNode.firstChild);
  3810. if(mediaNode)tweetNode.querySelector('[cta-id="main"]').appendChild(mediaNode.firstChild);
  3811. if(quotedNode)tweetNode.querySelector('[cta-id="main"]').appendChild(quotedNode.firstChild);
  3812. if(engagementsNode)tweetNode.querySelector('[cta-id="main"]').appendChild(engagementsNode.firstChild);
  3813. if(noAppend){
  3814. return tweetNode.firstChild;
  3815. }else{
  3816. appendParentNode.appendChild(tweetNode.firstChild);
  3817. return "finished";
  3818. }
  3819. async function tweetDataProsess(tweetData,tweetId){
  3820. let twitter_user_data = {};
  3821. let twitter_tweet_data = {};
  3822. let tweet_user_data_json = {};
  3823. let tweet_tweet_data_json = {};
  3824. tweet_user_data_json = tweetData.core?.user_results?.result || tweetData.user?.result || tweetData.user;
  3825. tweet_tweet_data_json = tweetData.legacy || tweetData;
  3826. if(!(tweet_user_data_json&&tweet_tweet_data_json)){
  3827. tweetData = await getTweetData(tweetId,'graphQL',true);
  3828. tweet_user_data_json = tweetData.core?.user_results?.result || tweetData.user?.result || tweetData.user;
  3829. tweet_tweet_data_json = tweetData.legacy || tweetData;
  3830. }
  3831. twitter_user_data.ID = tweet_user_data_json.rest_id || tweet_user_data_json.id_str;
  3832. twitter_user_data.screen_name = tweet_user_data_json.legacy?.screen_name || tweet_user_data_json.screen_name;
  3833. twitter_user_data.name = tweet_user_data_json.legacy?.name || tweet_user_data_json.name;
  3834. twitter_user_data.profile_image = tweet_user_data_json.legacy?.profile_image_url_https || tweet_user_data_json.profile_image_url_https;
  3835. twitter_user_data.urls = tweet_user_data_json.legacy?.entities || tweet_user_data_json.entities || [];
  3836. twitter_user_data.is_blue_verified = tweet_user_data_json.is_blue_verified || false;
  3837. twitter_user_data.profile_image_shape = tweet_user_data_json.profile_image_shape || "Circle";
  3838. twitter_user_data.protected = tweet_user_data_json.legacy?.protected || tweet_user_data_json.protected || false;
  3839. twitter_user_data.verified_type = tweet_user_data_json.legacy?.verified_type || false;
  3840. twitter_tweet_data.hashtags = tweet_tweet_data_json.entities.hashtags || [];
  3841. twitter_tweet_data.user_mentions = tweet_tweet_data_json.entities.user_mentions || [];
  3842. twitter_tweet_data.symbols = tweet_tweet_data_json.entities.symbols || [];
  3843. twitter_tweet_data.full_text = tweet_tweet_data_json.full_text || tweet_tweet_data_json.text || "";
  3844. twitter_tweet_data.extended_entities = tweet_tweet_data_json.extended_entities;
  3845. twitter_tweet_data.retweet_count = tweet_tweet_data_json.retweet_count;
  3846. twitter_tweet_data.favorite_count = tweet_tweet_data_json.favorite_count;
  3847. twitter_tweet_data.reply_count = tweet_tweet_data_json.reply_count || 0;
  3848. twitter_tweet_data.id = tweet_tweet_data_json.id_str;
  3849. twitter_tweet_data.created_at = tweet_tweet_data_json.created_at;
  3850. twitter_tweet_data.date = new Date(tweet_tweet_data_json.created_at);
  3851. twitter_tweet_data.urls = tweet_tweet_data_json.entities.urls;
  3852. twitter_tweet_data.media = twitter_tweet_data.extended_entities?.media || twitter_tweet_data.entities?.media;
  3853. twitter_tweet_data.favorited = ctaEngagementStore[twitter_tweet_data.id]?.favorited || tweet_tweet_data_json.favorited || false;
  3854. twitter_tweet_data.retweeted = ctaEngagementStore[twitter_tweet_data.id]?.retweeted || tweet_tweet_data_json.retweeted || false;
  3855. twitter_tweet_data.bookmarked = ctaEngagementStore[twitter_tweet_data.id]?.bookmarked || tweet_tweet_data_json.bookmarked || false;
  3856. twitter_tweet_data.analytics = tweetData.views?.count;
  3857. twitter_tweet_data.lang = tweet_tweet_data_json.lang;
  3858. try{
  3859. if(tweetData.note_tweet){
  3860. let note_tweet = tweetData.note_tweet?.note_tweet_results.result;
  3861. twitter_tweet_data.full_text = note_tweet.text;
  3862. twitter_tweet_data.urls = note_tweet.entity_set.urls;
  3863. twitter_tweet_data.hashtags = note_tweet.entity_set.hashtags || [];
  3864. twitter_tweet_data.user_mentions = note_tweet.entity_set.user_mentions || [];
  3865. twitter_tweet_data.symbols = note_tweet.entity_set.symbols || [];
  3866. }
  3867. }catch{}
  3868. if(twitter_tweet_data.favorited === true){
  3869. if(!ctaEngagementStore[twitter_tweet_data.id])ctaEngagementStore[twitter_tweet_data.id] = {};
  3870. ctaEngagementStore[twitter_tweet_data.id].favorited = true;
  3871. }
  3872. if(twitter_tweet_data.retweeted === true){
  3873. if(!ctaEngagementStore[twitter_tweet_data.id])ctaEngagementStore[twitter_tweet_data.id] = {};
  3874. ctaEngagementStore[twitter_tweet_data.id].retweeted = true;
  3875. }
  3876. if(twitter_tweet_data.bookmarked === true){
  3877. if(!ctaEngagementStore[twitter_tweet_data.id])ctaEngagementStore[twitter_tweet_data.id] = {};
  3878. ctaEngagementStore[twitter_tweet_data.id].bookmarked = true;
  3879. }
  3880. return {"tweetData": twitter_tweet_data, "userData": twitter_user_data};
  3881. }
  3882. function createHeaderNode(){
  3883. let node = document.createElement('div');
  3884. node.innerHTML = `
  3885. <div class="cta-base">
  3886. <div class="cta-base cta-flex-direction-row">
  3887. <div style="padding-top: calc(2.122%);" class="cta-base cta-flex-basis-0px cta-flex-grow-1"></div>
  3888. </div>
  3889. </div>
  3890. `.replace(/\t|\n/g, '');
  3891. return node;
  3892. }
  3893. function createAvatarNode(){
  3894. let node = document.createElement('div');
  3895. node.innerHTML = `
  3896. <div class="cta-base cta-flex-grow-0 cta-margin-right-big cta-flex-basis-icon cta-align-items-center" cta-id="avatar">
  3897. <div class="cta-base" data-testid="Tweet-User-Avatar">
  3898. <div class="cta-base cta-flex-grow-0 cta-flex-shrink-1 cta-width-100per">
  3899. <div class="cta-base cta-overflow-visible cta-display-block" style="width: 40px; height: 40px;" data-testid="UserAvatar-Container-${tweetData.userData.screen_name}">
  3900. <div class="cta-display-block cta-width-100per" style="padding-bottom: 100%;"></div>
  3901. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  3902. <div class="cta-base cta-display-block cta-height-100per cta-width-100per cta-position-absolute cta-arrangement-center cta-overflow-visible">
  3903. <div class="cta-display-block cta-width-100per" style="padding-bottom: 100%;"></div>
  3904. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  3905. <div class="cta-base ${tweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-position-absolute cta-icon-position-fix" style="width: calc(100% + 4px); height: calc(100% + 4px);">
  3906. <a href="/${tweetData.userData.screen_name}" aria-hidden="true" role="link" tabindex="-1" class="cta-base cta-height-100per cta-width-100per cta-transition-duration cta-transition-property cta-outline-style-none cta-cursor-pointer" style="background-color: rgba(0, 0, 0, 0);" target="_blank" rel="noopener noreferrer nofollow">
  3907. <div class="cta-base ${tweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-pointer-events-none cta-position-absolute cta-arrangement-center" style="width: calc(100% - 4px); height: calc(100% - 4px);">
  3908. <div class="cta-base cta-height-100per cta-width-100per" style="background-color: rgba(0, 0, 0, 0);"></div>
  3909. </div>
  3910. <div class="cta-base ${tweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-pointer-events-none cta-position-absolute cta-arrangement-center" style="width: calc(100% - 4px); height: calc(100% - 4px);">
  3911. <div class="cta-base cta-height-100per cta-width-100per"></div>
  3912. </div>
  3913. <div class="cta-base ${tweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-pointer-events-none cta-position-absolute cta-arrangement-center" style="background-color: ${colors.backgroundColor}; width: calc(100% - 4px); height: calc(100% - 4px);">
  3914. <div class="cta-base cta-display-block cta-overflow-hidden" style="">
  3915. <div class="cta-display-block cta-width-100per" style="padding-bottom: 100%;"></div>
  3916. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  3917. <div aria-label="" class="cta-base cta-flex-basis-auto cta-overflow-hidden cta-z-index-0" style="position: absolute; inset: 0px;">
  3918. <div class="cta-base cta-transparent-background cta-background-position-center cta-background-no-repeat cta-bottom-0px cta-height-100per cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-width-100per cta-z-index--1 cta-background-size-cover" style="background-image: url(&quot;${tweetData.userData.profile_image}&quot;);"></div>
  3919. <img alt="" draggable="true" src="${tweetData.userData.profile_image}" class="cta-img-css">
  3920. </div>
  3921. </div>
  3922. </div>
  3923. </div>
  3924. <div class="cta-base ${tweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-position-absolute cta-arrangement-center" style="width: calc(100% - 4px); height: calc(100% - 4px);">
  3925. <div class="cta-base cta-icon-box-shadow cta-height-100per cta-width-100per cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  3926. </div>
  3927. </a>
  3928. </div>
  3929. </div>
  3930. </div>
  3931. </div>
  3932. </div>
  3933. </div>
  3934. </div>
  3935. </div>
  3936. `.replace(/\t|\n/g, '');
  3937. return node;
  3938. }
  3939. function createAuthorNode(){
  3940. let authorNode = document.createElement('div');
  3941. authorNode.innerHTML = `
  3942. <div class="cta-base cta-margin-bottom-small">
  3943. <div class="cta-base cta-align-items-start cta-flex-direction-row cta-justify-content-space-between">
  3944. <div class="cta-base cta-align-items-baseline cta-flex-direction-row cta-flex-shrink-1" cta-id="Name-Place">
  3945. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none">
  3946. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none cta-align-items-center cta-flex-direction-row" id="" data-testid="User-Name">
  3947. <div class="cta-base cta-align-items-center cta-flex-direction-row cta-flex-shrink-1 cta-max-width-100per">
  3948. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per">
  3949. <a href="/${tweetData.userData.screen_name}" role="link" class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none cta-cursor-pointer" target="_blank" rel="noopener noreferrer nofollow">
  3950. <div class="cta-base cta-align-items-center cta-flex-direction-row cta-flex-shrink-1 cta-max-width-100per">
  3951. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-bold cta-align-items-center cta-display-flex cta-overflow-hidden cta-white-space-nowrap" style="color: ${colors.fontColor}; text-overflow: unset;">
  3952. <span class="cta-text2-css cta-max-width-100per cta-overflow-hidden cta-white-space-nowrap cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">
  3953. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">${tweetData.userData.name}</span>
  3954. </span>
  3955. </div>
  3956. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-display-inline-flex cta-flex-direction-row cta-flex-shrink-0" style="color: ${colors.fontColor}; text-overflow: unset;">
  3957. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-align-items-center cta-display-inline-flex" style="text-overflow: unset;" cta-id="account-status">
  3958. <!--鍵のアイコンとか-->
  3959. </span>
  3960. </div>
  3961. </div>
  3962. </a>
  3963. </div>
  3964. </div>
  3965. <div class="cta-base cta-flex-direction-row cta-flex-shrink-1" style="margin-left: 4px;">
  3966. <div class="cta-base cta-align-items-baseline cta-flex-direction-row cta-flex-shrink-1">
  3967. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per">
  3968. <a href="/${tweetData.userData.screen_name}" role="link" tabindex="-1" class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none cta-cursor-pointer" target="_blank" rel="noopener noreferrer nofollow">
  3969. <div dir="ltr" class="cta-text-css cta-max-width-100per cta-overflow-hidden cta-white-space-nowrap cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-flex-direction-row cta-font-feature-settings-ss01" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  3970. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">@${tweetData.userData.screen_name}</span>
  3971. </div>
  3972. </a>
  3973. </div>
  3974. <div dir="ltr" aria-hidden="true" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-flex-shrink-0 cta-side-padding-4px" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  3975. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">·</span>
  3976. </div>
  3977. <div class="cta-base cta-flex-direction-row cta-flex-shrink-0">
  3978. <a href="/${tweetData.userData.screen_name}/status/${tweetData.tweetData.id}" dir="ltr" aria-label="" role="link" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-display-inline-flex cta-flex-shrink-0 cta-flex-wrap-wrap cta-gap-4px cta-white-space-nowrap cta-cursor-pointer" style="color: ${colors.fontColorDark}; text-overflow: unset;" target="_blank" rel="noopener noreferrer nofollow">
  3979. <time datetime="${tweetData.tweetData.date.toISOString()}">${tweetData.tweetData.date.toLocaleDateString(GetCookie('lang'), {month: 'long', day: 'numeric'})}</time>
  3980. </a>
  3981. </div>
  3982. </div>
  3983. </div>
  3984. </div>
  3985. </div>
  3986. </div>
  3987. <div class="cta-base" style="margin-left: 8px;">
  3988. <div class="cta-base cta-align-items-center cta-flex-direction-row cta-gap-8px cta-justify-content-space-between">
  3989. <div class="cta-base cta-align-items-center cta-display-flex cta-flex-direction-row">
  3990. <div class="cta-base">
  3991. <div class="cta-base cta-flex-direction-row cta-justify-content-flex-start">
  3992. <div aria-expanded="false" aria-haspopup="menu" aria-label="もっと見る" role="button" tabindex="0" class="cta-base cta-justify-content-center cta-min-height-20px cta-overflow-visible cta-user-select-none cta-cursor-pointer cta-outline-style-none" data-testid="caret">
  3993. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-align-items-center cta-display-flex cta-justify-content-flex-start cta-transition-duration cta-svg-transition-property-color cta-white-space-nowrap" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  3994. <div class="cta-base cta-display-inline-flex">
  3995. <div class="cta-base cta-display-inline-flex cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-transparent-background cta-shape-circle cta-margin--8px cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  3996. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-height cta-svg-width">
  3997. <g><path d="M3 12c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2zm9 2c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm7 0c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"></path></g>
  3998. </svg>
  3999. </div>
  4000. </div>
  4001. </div>
  4002. </div>
  4003. </div>
  4004. </div>
  4005. </div>
  4006. </div>
  4007. </div>
  4008. </div>
  4009. `.replace(/\t|\n/g, '');
  4010. authorNode = appendAccountStatusIcon(authorNode,tweetData);
  4011. return authorNode;
  4012. }
  4013. function createTextNode(isQuoted = false){
  4014. let currentTweetData;
  4015. if(isQuoted){
  4016. currentTweetData = quotedTweetData;
  4017. }else{
  4018. currentTweetData = tweetData;
  4019. }
  4020. if(!currentTweetData.tweetData.full_text)return null;
  4021. let textNode = document.createElement('div');
  4022. textNode.innerHTML = `<div class="cta-base" cta-id="tweetMainText"><div dir="auto" lang="${currentTweetData.tweetData.lang}" class="cta-text-css cta-box-orient-vertical cta-max-width-100per cta-overflow-hidden cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-position-relative" style="color: ${colors.fontColor}; text-overflow: unset; display: -webkit-box; ${isQuoted === true ? '' : "margin-top: 4px;"}" id="" data-testid="tweetText"><span class="cta-text2-css rcta-min-width-0px cta-overflow-wrap-break-word cta-font-family">${tweetTextProsser(currentTweetData.tweetData.full_text,currentTweetData.tweetData.hashtags,currentTweetData.tweetData.user_mentions,currentTweetData.tweetData.symbols,currentTweetData.tweetData.urls,currentTweetData.tweetData.media)}</span></div></div>`;
  4023. return textNode;
  4024. }
  4025. function createMediaNode(isQuoted = false){
  4026. let currentTweetData;
  4027. if(isQuoted){
  4028. currentTweetData = quotedTweetData;
  4029. }else{
  4030. currentTweetData = tweetData;
  4031. }
  4032. if(!currentTweetData.tweetData.media)return null;
  4033. let medias = currentTweetData.tweetData.media;
  4034. let mediaNode = document.createElement('div');
  4035. mediaNode.innerHTML = `
  4036. <div aria-labelledby="" class="cta-base cta-gap-12px cta-margin-top">
  4037. <div class="cta-base cta-gap-4px">
  4038. <div class="cta-base">
  4039. <div class="cta-base" cta-id="mediaContainer">
  4040. <div class="cta-base cta-border cta-border-radius-16px cta-overflow-hidden cta-transition-duration cta-transition-property cta-outline-style-none" cta-id="mediaRoot">
  4041. </div>
  4042. </div>
  4043. </div>
  4044. </div>
  4045. </div>
  4046. `.replace(/\t|\n/g, '');
  4047. let mediaBox = document.createElement('div');
  4048. switch(medias.length){
  4049. case 1:
  4050. let imageHeight;
  4051. if(medias[0].type === "photo"){
  4052. const elementWidth = appendParentNode.clientWidth;
  4053. const displayWidth = elementWidth * 0.856;
  4054. const imagesize = medias[0].original_info || Object.entries(medias[0].sizes).filter(([key]) => key !== 'thumb').reduce((largest, current) => current[1].w > largest[1].w ? current : largest)[1];
  4055. const aspectRatio = (imagesize.width || imagesize.w) / (imagesize.height || imagesize.h);
  4056. imageHeight = displayWidth / aspectRatio;
  4057. }
  4058. mediaBox.innerHTML = `
  4059. <div class="cta-base" cta-id="media1" style="max-height:82vh;width: 100%; ${medias[0].type === "photo" ? `height:${imageHeight}px` : ''}">
  4060. <!--ここにメディア-->
  4061. </div>
  4062. `.replace(/\t|\n/g, '');
  4063. break;
  4064. case 2:
  4065. mediaBox.innerHTML = `
  4066. <div class="cta-base cta-display-block cta-overflow-hidden">
  4067. <div class="cta-display-block cta-width-100per" style="padding-bottom: 56.25%;"></div>
  4068. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4069. <div class="cta-base cta-height-100per cta-width-100per cta-flex-direction-row">
  4070. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative cta-margin-right-small" cta-id="media1">
  4071. <!--ここにメディア-->
  4072. </div>
  4073. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative" cta-id="media2">
  4074. <!--ここにメディア-->
  4075. </div>
  4076. </div>
  4077. </div>
  4078. </div>
  4079. `.replace(/\t|\n/g, '');
  4080. break;
  4081. case 3:
  4082. mediaBox.innerHTML = `
  4083. <div class="cta-base cta-display-block cta-overflow-hidden">
  4084. <div class="cta-display-block cta-width-100per" style="padding-bottom: 56.25%;"></div>
  4085. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4086. <div class="cta-base cta-height-100per cta-width-100per cta-flex-direction-row">
  4087. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative cta-margin-right-small" cta-id="media1">
  4088. <!--ここにメディア-->
  4089. </div>
  4090. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-flex-direction-column">
  4091. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative cta-margin-bottom-small" cta-id="media2">
  4092. <!--ここにメディア-->
  4093. </div>
  4094. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative" cta-id="media3">
  4095. <!--ここにメディア-->
  4096. </div>
  4097. </div>
  4098. </div>
  4099. </div>
  4100. </div>
  4101. `.replace(/\t|\n/g, '');
  4102. break;
  4103. case 4:
  4104. mediaBox.innerHTML = `
  4105. <div class="cta-base cta-display-block cta-overflow-hidden">
  4106. <div class="cta-display-block cta-width-100per" style="padding-bottom: 56.25%;"></div>
  4107. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4108. <div class="cta-base cta-height-100per cta-width-100per cta-flex-direction-column">
  4109. <div class="cta-base cta-margin-bottom-small cta-flex-basis-0px cta-flex-grow-1 cta-flex-direction-row">
  4110. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative cta-margin-right-small" cta-id="media1">
  4111. <!--ここにメディア-->
  4112. </div>
  4113. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative" cta-id="media2">
  4114. <!--ここにメディア-->
  4115. </div>
  4116. </div>
  4117. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-flex-direction-row">
  4118. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative cta-margin-right-small" cta-id="media3">
  4119. <!--ここにメディア-->
  4120. </div>
  4121. <div class="cta-base cta-flex-basis-0px cta-flex-grow-1 cta-position-relative" cta-id="media4">
  4122. <!--ここにメディア-->
  4123. </div>
  4124. </div>
  4125. </div>
  4126. </div>
  4127. </div>
  4128. `.replace(/\t|\n/g, '');
  4129. break;
  4130. }
  4131. for(let i=0;i<medias.length;i++){
  4132. let media = medias[i];
  4133. let tmp = document.createElement('div');
  4134. switch(media.type){
  4135. case "photo":
  4136. tmp.innerHTML = `
  4137. <div class="cta-base cta-flex-grow-1 cta-height-100per cta-width-100per">
  4138. <a href="${media.expanded_url.replace(/1$/,i+1)}" role="link" class="cta-base cta-height-100per cta-outline-style-none cta-cursor-pointer" target="_blank" rel="noopener noreferrer nofollow">
  4139. <div class="cta-base cta-bottom-0px cta-left-0px cta-overflow-hidden cta-position-absolute cta-right-0px cta-top-0px">
  4140. <div aria-label="画像" class="cta-base cta-flex-basis-auto cta-overflow-hidden cta-z-index-0" style="position: absolute; inset: 0px; margin: 0px;" data-testid="tweetPhoto">
  4141. <div class="cta-base cta-transparent-background cta-background-position-center cta-background-no-repeat cta-bottom-0px cta-height-100per cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-width-100per cta-z-index--1 cta-background-size-cover" style="background-image: url(&quot;${media.media_url_https}&quot;); ${medias.length === 1 ? "background-size: 100% auto;" : ""}"></div>
  4142. <img alt="画像" draggable="true" src="${media.media_url_https}" class="cta-img-css">
  4143. </div>
  4144. </div>
  4145. </a>
  4146. </div>
  4147. `.replace(/\t|\n/g, '');
  4148. break;
  4149. case "video":
  4150. tmp.innerHTML = `
  4151. <div class="cta-base cta-height-100per" data-testid="tweetPhoto">
  4152. <div class="cta-base">
  4153. <div class="cta-base cta-display-block cta-overflow-hidden">
  4154. <div class="cta-display-block cta-width-100per" style="padding-bottom: 56.0784%;"></div>
  4155. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4156. <div class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px" data-testid="placementTracking">
  4157. <div class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px" data-testid="videoPlayer">
  4158. <div class="cta-base cta-display-block cta-overflow-hidden cta-position-relative cta-height-100per cta-width-100per">
  4159. <div class="cta-display-block cta-width-100per" style="padding-bottom: 56.0784%;"></div>
  4160. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4161. <div data-testid="videoComponent" style="height: 100%; position: relative; transform: translateZ(0px); width: 100%;">
  4162. <div style="height: 100%; position: absolute; width: 100%;">
  4163. <div style="position: relative; width: 100%; height: 100%; background-color: transparent; overflow: hidden;">
  4164. <video preload="none" tabindex="-1" playsinline="" aria-label="埋め込み動画" style="width: 100%; height: 100%; position: absolute; background-color: black; top: 0%; left: 0%; transform: rotate(0deg) scale(1.005);" poster="${media.media_url_https}" src="${media.video_info.variants.filter(obj => obj.content_type !== 'application/x-mpegURL').reduce((a, b) => a.bitrate > b.bitrate ? a : b).url.split('?')[0]}" type="video/mp4" controls=""></video>
  4165. </div>
  4166. </div>
  4167. <!--
  4168. <div tabindex="0" class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px">
  4169. <div class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px">
  4170. <div class="cta-base cta-bottom-0px cta-cursor-pointer cta-left-0px cta-position-absolute cta-right-0px cta-top-0px" data-testid="video-player-mini-ui-"></div>
  4171. <div class="cta-base cta-flex-direction-row cta-position-absolute r-rki7wi r-161ttwi cta-pointer-events-none">
  4172. <div class="cta-base cta-align-items-center r-k200y r-z2wwpe r-z80fyv cta-justify-content-center r-13w96dm cta-flex-direction-row r-mk0yit r-rjfia r-6t5ypu r-kicko2 r-1dpl46z r-notknq cta-pointer-events-none">
  4173. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family r-q4m81j r-n6v787 r-1cwl3u0 cta-font-normal cta-user-select-none" style="color: rgb(255, 255, 255); text-overflow: unset;">
  4174. <div class="cta-base cta-align-items-center cta-display-flex cta-flex-direction-row">
  4175. <div aria-label="一時停止" role="button" tabindex="0" class="cta-base cta-display-inline-flex r-tuq35u cta-pointer-events-auto cta-cursor-pointer cta-transition-duration cta-transition-property cta-outline-style-none">
  4176. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none r-tbmifm r-16eto9q">
  4177. <g><path d="M4 2h5v20H4V2zm11 20h5V2h-5v20z"></path></g>
  4178. </svg>
  4179. </div>
  4180. </div>
  4181. </div>
  4182. </div>
  4183. </div>
  4184. <div style="transition-duration: 250ms; transition-property: opacity, height; transition-timing-function: ease; will-change: opacity; opacity: 0;"></div>
  4185. </div>
  4186. </div>
  4187. -->
  4188. </div>
  4189. </div>
  4190. </div>
  4191. </div>
  4192. </div>
  4193. </div>
  4194. </div>
  4195. </div>
  4196. </div>
  4197. `.replace(/\t|\n/g, '');
  4198. break;
  4199. case "animated_gif":
  4200. tmp.innerHTML = `
  4201. <div class="cta-base cta-height-100per" data-testid="tweetPhoto">
  4202. <div class="cta-base">
  4203. <div class="cta-base cta-display-block cta-overflow-hidden">
  4204. <div class="cta-display-block cta-width-100per" style="padding-bottom: 56.0784%;"></div>
  4205. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4206. <div class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px" data-testid="placementTracking">
  4207. <div class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px" data-testid="videoPlayer">
  4208. <div class="cta-base cta-display-block cta-overflow-hidden cta-position-relative cta-height-100per cta-width-100per">
  4209. <div class="cta-display-block cta-width-100per" style="padding-bottom: 56.0784%;"></div>
  4210. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4211. <div data-testid="videoComponent" style="height: 100%; position: relative; transform: translateZ(0px); width: 100%;">
  4212. <div style="height: 100%; position: absolute; width: 100%;">
  4213. <div style="position: relative; width: 100%; height: 100%; background-color: transparent; overflow: hidden;">
  4214. <video loop preload="auto" tabindex="-1" playsinline autoplay muted aria-label="埋め込み動画" style="width: 100%; height: 100%; position: absolute; background-color: black; top: 0%; left: 0%; transform: rotate(0deg) scale(1.005);" poster="${media.media_url_https}" src="${media.video_info.variants.filter(obj => obj.content_type !== 'application/x-mpegURL').reduce((a, b) => a.bitrate > b.bitrate ? a : b).url.split('?')[0]}" type="video/mp4"></video>
  4215. </div>
  4216. </div>
  4217. <!--
  4218. <div tabindex="0" class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px">
  4219. <div class="cta-base cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px">
  4220. <div class="cta-base cta-bottom-0px cta-cursor-pointer cta-left-0px cta-position-absolute cta-right-0px cta-top-0px" data-testid="video-player-mini-ui-"></div>
  4221. <div class="cta-base cta-flex-direction-row cta-position-absolute r-rki7wi r-161ttwi cta-pointer-events-none">
  4222. <div class="cta-base cta-align-items-center r-k200y r-z2wwpe r-z80fyv cta-justify-content-center r-13w96dm cta-flex-direction-row r-mk0yit r-rjfia r-zmljjp r-t12b5v r-6t5ypu r-kicko2 cta-margin-right-small cta-pointer-events-none">
  4223. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family r-q4m81j r-n6v787 r-1cwl3u0 cta-font-normal cta-user-select-none" style="color: rgb(255, 255, 255); text-overflow: unset;">
  4224. <div class="cta-base cta-align-items-center cta-display-flex cta-flex-direction-row">
  4225. <div aria-label="プレイ" role="button" tabindex="0" class="cta-base cta-display-inline-flex r-tuq35u cta-pointer-events-auto cta-cursor-pointer cta-transition-duration cta-transition-property cta-outline-style-none">
  4226. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none r-tbmifm r-16eto9q">
  4227. <g><path d="M21 12L4 2v20l17-10z"></path></g>
  4228. </svg>
  4229. </div>
  4230. </div>
  4231. </div>
  4232. </div>
  4233. <div class="cta-base cta-align-items-center r-k200y r-z2wwpe r-z80fyv cta-justify-content-center cta-side-padding-4px r-13w96dm r-pm2fo r-ou6ah9 r-1dpl46z r-notknq cta-pointer-events-none">
  4234. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family r-q4m81j r-n6v787 r-1cwl3u0 cta-font-bold cta-user-select-none" style="color: rgb(255, 255, 255); text-overflow: unset;">
  4235. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">GIF</span>
  4236. </div>
  4237. </div>
  4238. </div>
  4239. <div style="transition-duration: 250ms; transition-property: opacity, height; transition-timing-function: ease; will-change: opacity; opacity: 0;"></div>
  4240. </div>
  4241. </div>
  4242. -->
  4243. </div>
  4244. </div>
  4245. </div>
  4246. </div>
  4247. </div>
  4248. </div>
  4249. </div>
  4250. </div>
  4251. </div>
  4252. `.replace(/\t|\n/g, '');
  4253. let video = tmp.querySelector('video');
  4254. tmp.querySelector('video').addEventListener('click', function(){
  4255. if(video.paused){
  4256. video.play();
  4257. }else{
  4258. video.pause();
  4259. }
  4260. });
  4261. break;
  4262. }
  4263. mediaBox.querySelector(`[cta-id="media${i+1}"]`).appendChild(tmp.firstChild);
  4264. }
  4265. if(isQuoted){
  4266. return mediaBox;
  4267. }else{
  4268. mediaNode.querySelector('[cta-id="mediaRoot"]').appendChild(mediaBox.firstChild);
  4269. return mediaNode;
  4270. }
  4271. }
  4272. function createQuotedNode(){
  4273. if(!quotedTweetData)return null;
  4274. let node = document.createElement('div');
  4275. node.innerHTML =`
  4276. <div aria-labelledby="" class="cta-base cta-gap-12px cta-margin-top" cta-id="quoted-place">
  4277. <div class="cta-base">
  4278. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-overflow-hidden cta-position-absolute" style="color: ${colors.fontColor}; text-overflow: unset; border-width: 0px; clip: rect(1px, 1px, 1px, 1px); height: 1px; width: 1px; padding: 0px;">
  4279. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">引用</span>
  4280. </div>
  4281. <div tabindex="0" class="cta-base cta-overflow-hidden cta-border-radius-16px cta-transition-duration cta-transition-property cta-outline-style-none cta-cursor-pointer" role="link" style="min-height: 64px; border-width: 1px; border-color:${colors.borderBottomColor}">
  4282. <div class="cta-base">
  4283. <div class="cta-base cta-flex-direction-column cta-side-margin-12px cta-margin-top">
  4284. <div class="cta-base cta-align-items-center cta-flex-direction-row cta-flex-shrink-1">
  4285. <div class="cta-base cta-flex-shrink-1 cta-overflow-hidden">
  4286. <div class="cta-base cta-flex-direction-row cta-max-width-100per" style="align-items: flex-start;">
  4287. <div class="cta-base" data-testid="Tweet-User-Avatar" style="margin-right: 4px;">
  4288. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per">
  4289. <div class="cta-base cta-display-block cta-overflow-visible" style="width: 20px; height: 20px;" data-testid="UserAvatar-Container-${quotedTweetData.userData.screen_name}">
  4290. <div class="cta-display-block cta-width-100per" style="padding-bottom: 100%;"></div>
  4291. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4292. <div class="cta-base cta-display-block cta-height-100per cta-width-100per cta-position-absolute cta-arrangement-center cta-overflow-visible">
  4293. <div class="cta-display-block cta-width-100per" style="padding-bottom: 100%;"></div>
  4294. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4295. <div class="cta-base ${quotedTweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-position-absolute cta-icon-position-fix" style="width: calc(100% + 4px); height: calc(100% + 4px);">
  4296. <div aria-hidden="true" role="presentation" tabindex="-1" class="cta-base cta-height-100per cta-width-100per cta-outline-style-none" style="background-color: rgba(0, 0, 0, 0);">
  4297. <div class="cta-base ${quotedTweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-pointer-events-none cta-position-absolute cta-arrangement-center" style="width: calc(100% - 4px); height: calc(100% - 4px);">
  4298. <div class="cta-base cta-height-100per cta-width-100per" style="background-color: rgba(0, 0, 0, 0);"></div>
  4299. </div>
  4300. <div class="cta-base ${quotedTweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-pointer-events-none cta-position-absolute cta-arrangement-center" style="width: calc(100% - 4px); height: calc(100% - 4px);">
  4301. <div class="cta-base cta-height-100per cta-width-100per"></div>
  4302. </div>
  4303. <div class="cta-base ${quotedTweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-pointer-events-none cta-position-absolute cta-arrangement-center" style="background-color: ${colors.backgroundColor}; width: calc(100% - 4px); height: calc(100% - 4px);">
  4304. <div class="cta-base cta-display-block cta-overflow-hidden">
  4305. <div class="cta-display-block cta-width-100per" style="padding-bottom: 100%;"></div>
  4306. <div class="cta-bottom-0px cta-height-100per cta-position-absolute cta-left-0px cta-top-0px cta-width-100per">
  4307. <div aria-label="" class="cta-base cta-flex-basis-auto cta-overflow-hidden cta-z-index-0" style="position: absolute; inset: 0px;">
  4308. <div class="cta-base cta-transparent-background cta-background-position-center cta-background-no-repeat cta-bottom-0px cta-height-100per cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-width-100per cta-z-index--1 cta-background-size-cover" style="background-image: url(&quot;${quotedTweetData.userData.profile_image}&quot;);"></div>
  4309. <img alt="" draggable="true" src="${quotedTweetData.userData.profile_image}" class="cta-img-css">
  4310. </div>
  4311. </div>
  4312. </div>
  4313. </div>
  4314. <div class="cta-base ${quotedTweetData.userData.profile_image_shape === "Square" ? 'cta-shape-square' : 'cta-shape-circle'} cta-overflow-hidden cta-position-absolute cta-arrangement-center" style="width: calc(100% - 4px); height: calc(100% - 4px);">
  4315. <div class="cta-base cta-icon-box-shadow cta-height-100per cta-width-100per cta-outline-style-none"></div>
  4316. </div>
  4317. </div>
  4318. </div>
  4319. </div>
  4320. </div>
  4321. </div>
  4322. </div>
  4323. </div>
  4324. </div>
  4325. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none">
  4326. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none cta-align-items-center cta-flex-direction-row" data-testid="User-Name">
  4327. <div class="cta-base cta-align-items-center cta-flex-direction-row cta-flex-shrink-1 cta-max-width-100per">
  4328. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per">
  4329. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none">
  4330. <div class="cta-base cta-align-items-center cta-flex-direction-row cta-flex-shrink-1 cta-max-width-100per">
  4331. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-bold cta-align-items-center cta-display-flex cta-overflow-hidden cta-white-space-nowrap" style="color: ${colors.fontColor}; text-overflow: unset;">
  4332. <span class="cta-text2-css cta-max-width-100per cta-overflow-hidden cta-white-space-nowrap cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">
  4333. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">${quotedTweetData.userData.name}</span>
  4334. </span>
  4335. </div>
  4336. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-display-inline-flex cta-flex-direction-row cta-flex-shrink-0" style="color: ${colors.fontColor}; text-overflow: unset;">
  4337. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-align-items-center cta-display-inline-flex" style="text-overflow: unset;" cta-id="account-status">
  4338. <!--鍵のアイコンとか-->
  4339. </span>
  4340. </div>
  4341. </div>
  4342. </div>
  4343. </div>
  4344. </div>
  4345. <div class="cta-base cta-flex-direction-row cta-flex-shrink-1" style="margin-left: 4px;">
  4346. <div class="cta-base cta-align-items-baseline cta-flex-direction-row cta-flex-shrink-1">
  4347. <div class="cta-base cta-flex-shrink-1 cta-max-width-100per">
  4348. <div tabindex="-1" class="cta-base cta-flex-shrink-1 cta-max-width-100per cta-outline-style-none">
  4349. <div dir="ltr" class="cta-text-css cta-max-width-100per cta-overflow-hidden cta-white-space-nowrap cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-flex-direction-row cta-font-feature-settings-ss01" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  4350. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">@${quotedTweetData.userData.screen_name}</span>
  4351. </div>
  4352. </div>
  4353. </div>
  4354. <div dir="ltr" aria-hidden="true" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-flex-shrink-0 cta-side-padding-4px" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  4355. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">·</span>
  4356. </div>
  4357. <div class="cta-base cta-flex-direction-row cta-flex-shrink-0">
  4358. <div class="cta-base cta-align-items-baseline cta-flex-direction-row cta-flex-shrink-1">
  4359. <div dir="ltr" aria-label="" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-display-inline-flex cta-flex-shrink-0 cta-flex-wrap-wrap cta-gap-4px cta-white-space-nowrap" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  4360. <time datetime="${quotedTweetData.tweetData.date.toISOString()}">${quotedTweetData.tweetData.date.toLocaleDateString(GetCookie('lang'), {month: 'long', day: 'numeric'})}</time>
  4361. </div>
  4362. </div>
  4363. </div>
  4364. </div>
  4365. </div>
  4366. </div>
  4367. </div>
  4368. </div>
  4369. </div>
  4370. </div>
  4371. </div>
  4372. <div class="cta-base cta-side-margin-12px" style="margin-bottom: 12px;" cta-id="quoted-text">
  4373. <!--ここにテキスト -->
  4374. </div>
  4375. <div class="cta-base" style="margin-top: 4px;">
  4376. <div class="cta-base">
  4377. <div class="cta-base cta-transition-duration cta-transition-property cta-outline-style-none" cta-id="quoted-media">
  4378. <!--引用のメディア-->
  4379. </div>
  4380. </div>
  4381. </div>
  4382. </div>
  4383. </div>
  4384. </div>
  4385. </div>
  4386. `.replace(/\t|\n/g, '');
  4387. node = appendAccountStatusIcon(node,quotedTweetData)
  4388. let textNode = createTextNode(true);
  4389. let mediaNode = createMediaNode(true);
  4390. if(textNode)node.querySelector('[cta-id="quoted-text"]').appendChild(textNode.firstChild.firstChild);
  4391. if(mediaNode)node.querySelector('[cta-id="quoted-media"]').appendChild(mediaNode.firstChild);
  4392. return node;
  4393. }
  4394. function createEngagementNode(){
  4395. let engagementNode = document.createElement('div');
  4396. let retweetPath = 'M4.5 3.88l4.432 4.14-1.364 1.46L5.5 7.55V16c0 1.1.896 2 2 2H13v2H7.5c-2.209 0-4-1.79-4-4V7.55L1.432 9.48.068 8.02 4.5 3.88zM16.5 6H11V4h5.5c2.209 0 4 1.79 4 4v8.45l2.068-1.93 1.364 1.46-4.432 4.14-4.432-4.14 1.364-1.46 2.068 1.93V8c0-1.1-.896-2-2-2z';
  4397. let retweetedPath = 'M4.75 3.79l4.603 4.3-1.706 1.82L6 8.38v7.37c0 .97.784 1.75 1.75 1.75H13V20H7.75c-2.347 0-4.25-1.9-4.25-4.25V8.38L1.853 9.91.147 8.09l4.603-4.3zm11.5 2.71H11V4h5.25c2.347 0 4.25 1.9 4.25 4.25v7.37l1.647-1.53 1.706 1.82-4.603 4.3-4.603-4.3 1.706-1.82L18 15.62V8.25c0-.97-.784-1.75-1.75-1.75z';
  4398. let likedPath = 'M20.884 13.19c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z';
  4399. let likePath = 'M16.697 5.5c-1.222-.06-2.679.51-3.89 2.16l-.805 1.09-.806-1.09C9.984 6.01 8.526 5.44 7.304 5.5c-1.243.07-2.349.78-2.91 1.91-.552 1.12-.633 2.78.479 4.82 1.074 1.97 3.257 4.27 7.129 6.61 3.87-2.34 6.052-4.64 7.126-6.61 1.111-2.04 1.03-3.7.477-4.82-.561-1.13-1.666-1.84-2.908-1.91zm4.187 7.69c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z';
  4400. let bookmarkedPath = 'M4 4.5C4 3.12 5.119 2 6.5 2h11C18.881 2 20 3.12 20 4.5v18.44l-8-5.71-8 5.71V4.5z';
  4401. let bookmarkPath = 'M4 4.5C4 3.12 5.119 2 6.5 2h11C18.881 2 20 3.12 20 4.5v18.44l-8-5.71-8 5.71V4.5zM6.5 4c-.276 0-.5.22-.5.5v14.56l6-4.29 6 4.29V4.5c0-.28-.224-.5-.5-.5h-11z';
  4402. engagementNode.innerHTML = `
  4403. <div class="cta-base" cta-id="footer">
  4404. <div class="cta-base">
  4405. <div aria-label="0 件のリツイート、リツイートしました、0 件の表示" role="group" class="cta-base cta-column-gap-4px cta-flex-direction-row cta-justify-content-space-between cta-max-width-600px cta-margin-top" id="">
  4406. <div class="cta-base cta-flex-direction-row cta-justify-content-flex-start cta-flex-1-1-0per">
  4407. <div aria-label="0 件の返信。返信する" role="button" tabindex="0" class="cta-base cta-justify-content-center cta-min-height-20px cta-overflow-visible cta-user-select-none cta-cursor-pointer cta-outline-style-none" data-testid="reply" style="opacity: 0.5;">
  4408. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-align-items-center cta-display-flex cta-justify-content-flex-start cta-transition-duration cta-svg-transition-property-color cta-white-space-nowrap" style="text-overflow: unset; color: ${colors.fontColorDark};">
  4409. <div class="cta-base cta-display-inline-flex">
  4410. <div class="cta-base cta-display-inline-flex cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-transparent-background cta-shape-circle cta-margin--8px cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  4411. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-height cta-svg-width">
  4412. <g><path d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z"></path></g>
  4413. </svg>
  4414. </div>
  4415. <div class="cta-base cta-display-inline-flex cta-overflow-hidden">
  4416. <span data-testid="app-text-transition-container" style="transition-property: transform; transition-duration: 0.3s; transform: translate3d(0px, 0px, 0px);"><span class="cta-text2-css cta-overflow-wrap-break-word cta-font-family cta-engagement-text" style="text-overflow: unset;">
  4417. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;" cta-id="reply-text">${tweetData.tweetData.reply_count === 0 ? "" : round_half_up(tweetData.tweetData.reply_count,textData.roundingScale,textData.decimalPlaces,textData.units)}</span>
  4418. </span></span>
  4419. </div>
  4420. </div>
  4421. </div>
  4422. </div>
  4423. <div class="cta-base cta-flex-direction-row cta-justify-content-flex-start cta-flex-1-1-0per">
  4424. <div aria-expanded="false" aria-haspopup="menu" aria-label="0件のリツイート件。リツイートしました" role="button" tabindex="0" class="cta-base cta-justify-content-center cta-min-height-20px cta-overflow-visible cta-user-select-none cta-cursor-pointer cta-outline-style-none" data-testid="${ctaEngagementStore[tweetData.tweetData.id]?.retweeted === true ? 'un' : ""}retweet" cta-id="retweet">
  4425. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-align-items-center cta-display-flex cta-justify-content-flex-start cta-transition-duration cta-svg-transition-property-color cta-white-space-nowrap" style="color: ${ctaEngagementStore[tweetData.tweetData.id]?.retweeted === true ? 'rgb(0, 186, 124)' : colors.fontColorDark}; text-overflow: unset;">
  4426. <div class="cta-base cta-display-inline-flex">
  4427. <div class="cta-base cta-display-inline-flex cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-transparent-background cta-shape-circle cta-margin--8px cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  4428. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-height cta-svg-width">
  4429. <g><path d="${ctaEngagementStore[tweetData.tweetData.id]?.retweeted === true ? retweetedPath: retweetPath}"></path></g>
  4430. </svg>
  4431. </div>
  4432. <div class="cta-base cta-display-inline-flex cta-overflow-hidden">
  4433. <span data-testid="app-text-transition-container" style="transition-property: transform; transition-duration: 0.3s; transform: translate3d(0px, 0px, 0px);"><span class="cta-text2-css cta-overflow-wrap-break-word cta-font-family cta-engagement-text" style="text-overflow: unset;">
  4434. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;" cta-id="retweet-text">${tweetData.tweetData.retweet_count === 0 ? "" : round_half_up(tweetData.tweetData.retweet_count,textData.roundingScale,textData.decimalPlaces,textData.units)}</span>
  4435. </span></span>
  4436. </div>
  4437. </div>
  4438. </div>
  4439. </div>
  4440. <div class="cta-base cta-flex-direction-row cta-justify-content-flex-start cta-flex-1-1-0per">
  4441. <div aria-label="0 件のいいね。いいねする" role="button" tabindex="0" class="cta-base cta-justify-content-center cta-min-height-20px cta-overflow-visible cta-user-select-none cta-cursor-pointer cta-outline-style-none" data-testid="${ctaEngagementStore[tweetData.tweetData.id]?.favorited === true ? 'un' : ""}like" cta-id="like">
  4442. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-align-items-center cta-display-flex cta-justify-content-flex-start cta-transition-duration cta-svg-transition-property-color cta-white-space-nowrap" style="color: ${ctaEngagementStore[tweetData.tweetData.id]?.favorited === true ? 'rgb(249, 24, 128)' : colors.fontColorDark}; text-overflow: unset;">
  4443. <div class="cta-base cta-display-inline-flex">
  4444. <div class="cta-base cta-display-inline-flex cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-transparent-background cta-shape-circle cta-margin--8px cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  4445. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-height cta-svg-width">
  4446. <g><path d="${ctaEngagementStore[tweetData.tweetData.id]?.favorited === true ? likedPath: likePath}"></path></g>
  4447. </svg>
  4448. </div>
  4449. <div class="cta-base cta-display-inline-flex cta-overflow-hidden">
  4450. <span data-testid="app-text-transition-container" style="transition-property: transform; transition-duration: 0.3s; transform: translate3d(0px, 0px, 0px);"><span class="cta-text2-css cta-overflow-wrap-break-word cta-font-family cta-engagement-text" style="text-overflow: unset;">
  4451. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;" cta-id="like-text">${tweetData.tweetData.favorite_count === 0 ? "" : round_half_up(tweetData.tweetData.favorite_count,textData.roundingScale,textData.decimalPlaces,textData.units)}</span>
  4452. </span></span>
  4453. </div>
  4454. </div>
  4455. </div>
  4456. </div>
  4457. <div class="cta-base cta-flex-direction-row cta-justify-content-flex-start cta-flex-1-1-0per">
  4458. <a href="/${tweetData.tweetData.screen_name}/status/${tweetData.tweetData.id}/analytics" aria-label="0 件の表示。ツイートアナリティクスを表示" role="link" class="cta-base cta-justify-content-center cta-min-height-20px cta-overflow-visible cta-user-select-none cta-outline-style-none cta-cursor-pointer" target="_blank" rel="noopener noreferrer nofollow">
  4459. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-align-items-center cta-display-flex cta-justify-content-flex-start cta-transition-duration cta-svg-transition-property-color cta-white-space-nowrap" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  4460. <div class="cta-base cta-display-inline-flex">
  4461. <div class="cta-base cta-display-inline-flex cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-transparent-background cta-shape-circle cta-margin--8px cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  4462. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-height cta-svg-width">
  4463. <g><path d="M8.75 21V3h2v18h-2zM18 21V8.5h2V21h-2zM4 21l.004-10h2L6 21H4zm9.248 0v-7h2v7h-2z"></path></g>
  4464. </svg>
  4465. </div>
  4466. <div class="cta-base cta-display-inline-flex cta-overflow-hidden">
  4467. <span data-testid="app-text-transition-container" style="transition-property: transform; transition-duration: 0.3s; transform: translate3d(0px, 0px, 0px);"><span class="cta-text2-css cta-overflow-wrap-break-word cta-font-family cta-engagement-text" style="text-overflow: unset;">
  4468. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;" cta-id="analytics-text">${tweetData.tweetData.analytics === 0 ? "" : tweetData.tweetData.analytics || ""}</span>
  4469. </span></span>
  4470. </div>
  4471. </div>
  4472. </a>
  4473. </div>
  4474. <div class="cta-base cta-flex-direction-row cta-justify-content-flex-start" style="margin-right: 8px;">
  4475. <div aria-label="ブックマーク" role="button" tabindex="0" class="cta-base cta-justify-content-center cta-min-height-20px cta-overflow-visible cta-user-select-none cta-cursor-pointer cta-outline-style-none" data-testid="${ctaEngagementStore[tweetData.tweetData.id]?.bookmarked === true ? 'un' : ""}bookmark" cta-id="bookmark">
  4476. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-align-items-center cta-display-flex cta-justify-content-flex-start cta-transition-duration cta-svg-transition-property-color cta-white-space-nowrap" style="color: ${ctaEngagementStore[tweetData.tweetData.id]?.bookmarked === true ? 'rgb(29, 155, 240)' : colors.fontColorDark}; text-overflow: unset;">
  4477. <div class="cta-base cta-display-inline-flex">
  4478. <div class="cta-base cta-display-inline-flex cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-transparent-background cta-shape-circle cta-margin--8px cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  4479. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-height cta-svg-width">
  4480. <g><path d="${ctaEngagementStore[tweetData.tweetData.id]?.bookmarked === true ? bookmarkedPath : bookmarkPath}"></path></g>
  4481. </svg>
  4482. </div>
  4483. </div>
  4484. </div>
  4485. </div>
  4486. <div class="cta-base" style="transform: rotate(0deg) scale(1) translate3d(0px, 0px, 0px); justify-content: inherit; display: inline-grid;" cta-id="share-button">
  4487. <div class="cta-base cta-flex-direction-row cta-justify-content-flex-start">
  4488. <div aria-disabled="true" aria-expanded="false" aria-haspopup="menu" aria-label="ツイートを共有" role="button" tabindex="-1" class="cta-base cta-justify-content-center cta-min-height-20px cta-overflow-visible cta-user-select-none cta-outline-style-none">
  4489. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-provisional-font-family cta-font-size cta-line-height cta-font-normal cta-align-items-center cta-display-flex cta-justify-content-flex-start cta-transition-duration cta-svg-transition-property-color cta-white-space-nowrap" style="color: ${colors.fontColorDark}; text-overflow: unset;">
  4490. <div class="cta-base cta-display-inline-flex">
  4491. <div class="cta-base cta-display-inline-flex cta-bottom-0px cta-left-0px cta-position-absolute cta-right-0px cta-top-0px cta-transparent-background cta-transition-duration cta-transition-property cta-outline-style-none"></div>
  4492. <svg viewBox="0 0 24 24" aria-hidden="true" class="cta-display-inline-block cta-fill-currentcolor cta-max-width-100per cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-height cta-svg-width">
  4493. <g><path d="M12 2.59l5.7 5.7-1.41 1.42L13 6.41V16h-2V6.41l-3.3 3.3-1.41-1.42L12 2.59zM21 15l-.02 3.51c0 1.38-1.12 2.49-2.5 2.49H5.5C4.11 21 3 19.88 3 18.5V15h2v3.5c0 .28.22.5.5.5h12.98c.28 0 .5-.22.5-.5L19 15h2z"></path></g>
  4494. </svg>
  4495. </div>
  4496. </div>
  4497. </div>
  4498. </div>
  4499. </div>
  4500. </div>
  4501. </div>
  4502. </div>
  4503. `.replace(/\t|\n/g, '');
  4504. let currentTweetID = tweetData.tweetData.id;
  4505. let currentScreenName = tweetData.userData.screen_name;
  4506. let retweetNode = engagementNode.querySelector('[cta-id="retweet"]');
  4507. let likeNode = engagementNode.querySelector('[cta-id="like"]');
  4508. let bookmarkNode = engagementNode.querySelector('[cta-id="bookmark"]');
  4509. retweetNode.addEventListener('click',whenClickRetweet);
  4510. likeNode.addEventListener('click',whenClickLike);
  4511. bookmarkNode.addEventListener('click',whenClickBookmark);
  4512. engagementNode.querySelector('[cta-id="share-button"]').addEventListener('click',async function(){
  4513. copyToClipboard(`https://twitter.com/${currentScreenName}/status/${currentTweetID}`);
  4514. });
  4515. return engagementNode;
  4516.  
  4517. async function whenClickRetweet(event){
  4518. event.currentTarget.removeEventListener('click', whenClickRetweet);
  4519. if(!ctaEngagementStore[currentTweetID])ctaEngagementStore[currentTweetID] = {};
  4520. let countTextNode = retweetNode.querySelector('[cta-id="retweet-text"]');
  4521. let countText = Number(countTextNode.innerText);
  4522. try{
  4523. if(retweetNode.getAttribute('data-testid') === 'retweet'){
  4524. let resp = await request(new requestObject_twitter_CreateRetweet(currentTweetID));
  4525. if(!(resp.status === 200)){
  4526. displayToast(textData.faildRetweet);
  4527. return;
  4528. }
  4529. displayToast(textData.doneRetweet);
  4530. retweetNode.setAttribute('data-testid','unretweet');
  4531. retweetNode.firstChild.style.color = "rgb(0, 186, 124)";
  4532. retweetNode.querySelector('path').setAttribute('d',retweetedPath);
  4533. if(!isNaN(countText))countTextNode.innerText = Number(countTextNode.innerText) + 1;
  4534. ctaEngagementStore[currentTweetID].retweeted = true;
  4535. }else{
  4536. let resp = await request(new requestObject_twitter_DeleteRetweet(currentTweetID));
  4537. if(!(resp.status === 200)){
  4538. displayToast(textData.faildUnRetweet);
  4539. return;
  4540. }
  4541. displayToast(textData.unRetweet);
  4542. retweetNode.setAttribute('data-testid','retweet');
  4543. retweetNode.firstChild.style.color = colors.fontColorDark;
  4544. retweetNode.querySelector('path').setAttribute('d',retweetPath);
  4545. if(!isNaN(countText)){
  4546. if((Number(countTextNode.innerText) - 1)>0){
  4547. countTextNode.innerText = Number(countTextNode.innerText) - 1;
  4548. }else{
  4549. countTextNode.innerText = "";
  4550. }
  4551. }
  4552. ctaEngagementStore[currentTweetID].retweeted = false;
  4553. }
  4554. }catch(error){
  4555. console.error(error);
  4556. }finally{
  4557. retweetNode.addEventListener('click', whenClickRetweet);
  4558. }
  4559. }
  4560. async function whenClickLike(event){
  4561. event.currentTarget.removeEventListener('click', whenClickLike);
  4562. if(!ctaEngagementStore[currentTweetID])ctaEngagementStore[currentTweetID] = {};
  4563. let countTextNode = likeNode.querySelector('[cta-id="like-text"]');
  4564. let countText = Number(countTextNode.innerText);
  4565. try{
  4566. if(likeNode.getAttribute('data-testid') === 'like'){
  4567. let resp = await request(new requestObject_twitter_FavoriteTweet(currentTweetID));
  4568. if(!(resp.status === 200)){
  4569. displayToast(textData.faildRetweet);
  4570. return;
  4571. }
  4572. likeNode.setAttribute('data-testid','unlike');
  4573. likeNode.firstChild.style.color = "rgb(249, 24, 128)";
  4574. likeNode.querySelector('path').setAttribute('d',likedPath);
  4575. if(!isNaN(countText))countTextNode.innerText = Number(countTextNode.innerText) + 1;
  4576. ctaEngagementStore[currentTweetID].favorited = true;
  4577. }else{
  4578. let resp = await request(new requestObject_twitter_UnfavoriteTweet(currentTweetID));
  4579. console.log(resp)
  4580. if(!(resp.status === 200)){
  4581. displayToast(textData.faildUnRetweet);
  4582. return;
  4583. }
  4584. likeNode.setAttribute('data-testid','like');
  4585. likeNode.firstChild.style.color = colors.fontColorDark;
  4586. likeNode.querySelector('path').setAttribute('d',likePath);
  4587. if(!isNaN(countText)){
  4588. if((Number(countTextNode.innerText) - 1)>0){
  4589. countTextNode.innerText = Number(countTextNode.innerText) - 1;
  4590. }else{
  4591. countTextNode.innerText = "";
  4592. }
  4593. }
  4594. ctaEngagementStore[currentTweetID].favorited = false;
  4595. }
  4596. }catch(error){
  4597. console.error(error);
  4598. }finally{
  4599. likeNode.addEventListener('click', whenClickLike);
  4600. }
  4601. }
  4602. async function whenClickBookmark(event){
  4603. event.currentTarget.removeEventListener('click', whenClickBookmark);
  4604. if(!ctaEngagementStore[currentTweetID])ctaEngagementStore[currentTweetID] = {};
  4605. try{
  4606. if(bookmarkNode.getAttribute('data-testid') === 'bookmark'){
  4607. let resp = await request(new requestObject_twitter_CreateBookmark(currentTweetID));
  4608. if(!(resp.status === 200)){
  4609. displayToast(textData.faildRetweet);
  4610. return;
  4611. }
  4612. displayToast(textData.doneBookmark);
  4613. bookmarkNode.setAttribute('data-testid','unbookmark');
  4614. bookmarkNode.firstChild.style.color = "rgb(29, 155, 240)";
  4615. bookmarkNode.querySelector('path').setAttribute('d',bookmarkedPath);
  4616. ctaEngagementStore[currentTweetID].bookmarked = true;
  4617. }else{
  4618. let resp = await request(new requestObject_twitter_DeleteBookmark(currentTweetID));
  4619. if(!(resp.status === 200)){
  4620. displayToast(textData.faildUnRetweet);
  4621. return;
  4622. }
  4623. displayToast(textData.unBookmark);
  4624. bookmarkNode.setAttribute('data-testid','bookmark');
  4625. bookmarkNode.firstChild.style.color = colors.fontColorDark;
  4626. bookmarkNode.querySelector('path').setAttribute('d',bookmarkPath);
  4627. ctaEngagementStore[currentTweetID].bookmarked = false;
  4628. }
  4629. }catch(error){
  4630. console.error(error);
  4631. }finally{
  4632. bookmarkNode.addEventListener('click', whenClickBookmark);
  4633. }
  4634. }
  4635. }
  4636. function tweetTextProsser(text,hashtags,user_mentions,symbols,urls,media){
  4637. let link_class = 'cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family-inherit cta-cursor-pointer';
  4638. function countSurrogatePairs(str){
  4639. return Array.from(str).filter(char => char.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)).length;
  4640. }
  4641. let combined = [].concat(
  4642. hashtags.map(tag => ({
  4643. type: 'hashtag',
  4644. indices: tag.indices,
  4645. text: tag.text
  4646. })),
  4647. user_mentions.map(mention => ({
  4648. type: 'mention',
  4649. indices: mention.indices,
  4650. text: mention.screen_name
  4651. })),
  4652. symbols.map(symbol => ({
  4653. type: 'symbol',
  4654. indices: symbol.indices,
  4655. text: symbol.text
  4656. }))
  4657. );
  4658. // combinedをindicesの順にソート
  4659. combined.sort((a, b) => b.indices[0] - a.indices[0]);
  4660. let transformedText = text;
  4661.  
  4662. combined.forEach(item => {
  4663. let start = item.indices[0];
  4664. let end = item.indices[1];
  4665.  
  4666. // サロゲートペアの数をカウントして調整
  4667. const adjustment = countSurrogatePairs(transformedText.slice(0, end));
  4668. start += adjustment;
  4669. end += adjustment;
  4670.  
  4671. let replacement = '';
  4672. switch(item.type){
  4673. case 'hashtag':
  4674. replacement = `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="https://twitter.com/hashtag/${item.text}" target="_blank" rel="noopener noreferrer nofollow">#${item.text}</a>`;
  4675. break;
  4676. case 'mention':
  4677. replacement = `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="https://twitter.com/${item.text}" target="_blank" rel="noopener noreferrer nofollow">@${item.text}</a>`;
  4678. break;
  4679. case 'symbol':
  4680. replacement = `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="https://twitter.com/search?q=%24${item.text}&src=cashtag_click" target="_blank" rel="noopener noreferrer nofollow">$${item.text}</a>`;
  4681. break;
  4682. }
  4683. transformedText = transformedText.slice(0, start) + replacement + transformedText.slice(end);
  4684. });
  4685. text = transformedText;
  4686. urls?.forEach(target =>{
  4687. text = text.replace(new RegExp(`${target.url}(?=(\\s|$|\\u3000|\\W)(?!\\.|,))`, 'gu'), `<a class="${link_class}" style="text-decoration: none;color:rgb(29, 155, 240)" dir="ltr" role="link" href="${target.url}" target="_blank" rel="noopener noreferrer nofollow">${target.display_url}</a>`);
  4688. });
  4689. media?.forEach(m=>{
  4690. text = text.replace(m.url,'');
  4691. });
  4692. return text;
  4693. }
  4694. function appendAccountStatusIcon(node,tweetData){
  4695. let accountStatusNode = node.querySelector('[cta-id="account-status"]');
  4696. if(tweetData.userData.protected){
  4697. let iconLock = document.createElement('div');
  4698. iconLock.innerHTML = `
  4699. <svg viewBox="0 0 24 24" aria-label="非公開アカウント" role="img" class="cta-display-inline-block cta-fill-currentcolor cta-svg-height cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-margin-left-small cta-svg-max-height cta-svg-max-width" data-testid="icon-lock" style="color: ${colors.fontColor}">
  4700. <g><path d="M17.5 7H17v-.25c0-2.76-2.24-5-5-5s-5 2.24-5 5V7h-.5C5.12 7 4 8.12 4 9.5v9C4 19.88 5.12 21 6.5 21h11c1.39 0 2.5-1.12 2.5-2.5v-9C20 8.12 18.89 7 17.5 7zM13 14.73V17h-2v-2.27c-.59-.34-1-.99-1-1.73 0-1.1.9-2 2-2 1.11 0 2 .9 2 2 0 .74-.4 1.39-1 1.73zM15 7H9v-.25c0-1.66 1.35-3 3-3 1.66 0 3 1.34 3 3V7z"></path></g>
  4701. </svg>
  4702. `.replace(/\t|\n/g, '');
  4703. accountStatusNode.appendChild(iconLock.firstChild);
  4704. }
  4705. if(tweetData.userData.verified_type === "Business"){
  4706. let iconVerifiedBussiness = document.createElement('div');
  4707. iconVerifiedBussiness.innerHTML = `
  4708. <svg viewBox="0 0 22 22" aria-label="認証済みアカウント" role="img" class="cta-display-inline-block cta-fill-currentcolor cta-svg-height cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-max-height cta-svg-max-width cta-margin-left-small" data-testid="icon-verified">
  4709. <g>
  4710. <linearGradient gradientUnits="userSpaceOnUse" id="38-a" x1="4.411" x2="18.083" y1="2.495" y2="21.508">
  4711. <stop offset="0" stop-color="#f4e72a"></stop>
  4712. <stop offset=".539" stop-color="#cd8105"></stop>
  4713. <stop offset=".68" stop-color="#cb7b00"></stop>
  4714. <stop offset="1" stop-color="#f4ec26"></stop>
  4715. <stop offset="1" stop-color="#f4e72a"></stop>
  4716. </linearGradient>
  4717. <linearGradient gradientUnits="userSpaceOnUse" id="38-b" x1="5.355" x2="16.361" y1="3.395" y2="19.133">
  4718. <stop offset="0" stop-color="#f9e87f"></stop>
  4719. <stop offset=".406" stop-color="#e2b719"></stop>
  4720. <stop offset=".989" stop-color="#e2b719"></stop>
  4721. </linearGradient>
  4722. <g clip-rule="evenodd" fill-rule="evenodd">
  4723. <path d="M13.324 3.848L11 1.6 8.676 3.848l-3.201-.453-.559 3.184L2.06 8.095 3.48 11l-1.42 2.904 2.856 1.516.559 3.184 3.201-.452L11 20.4l2.324-2.248 3.201.452.559-3.184 2.856-1.516L18.52 11l1.42-2.905-2.856-1.516-.559-3.184zm-7.09 7.575l3.428 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z" fill="url(#38-a)"></path>
  4724. <path d="M13.101 4.533L11 2.5 8.899 4.533l-2.895-.41-.505 2.88-2.583 1.37L4.2 11l-1.284 2.627 2.583 1.37.505 2.88 2.895-.41L11 19.5l2.101-2.033 2.895.41.505-2.88 2.583-1.37L17.8 11l1.284-2.627-2.583-1.37-.505-2.88zm-6.868 6.89l3.429 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z" fill="url(#38-b)"></path>
  4725. <path d="M6.233 11.423l3.429 3.428 5.65-6.17.038-.033-.005 1.398-5.683 6.206-3.429-3.429-.003-1.405.005.003z" fill="#d18800"></path>
  4726. </g>
  4727. </g>
  4728. </svg>
  4729. `.replace(/\t|\n/g, '');
  4730. accountStatusNode.appendChild(iconVerifiedBussiness.firstChild);
  4731. }else if(tweetData.userData.is_blue_verified){
  4732. let iconVerified = document.createElement('div');
  4733. iconVerified.innerHTML = `
  4734. <svg viewBox="0 0 22 22" aria-label="認証済みアカウント" role="img" class="cta-display-inline-block cta-fill-currentcolor cta-svg-height cta-position-relative cta-vertical-align-text-bottom cta-user-select-none cta-svg-max-height cta-svg-max-width cta-margin-left-small" data-testid="icon-verified" style="color: rgb(29, 155, 240);">
  4735. <g><path d="M20.396 11c-.018-.646-.215-1.275-.57-1.816-.354-.54-.852-.972-1.438-1.246.223-.607.27-1.264.14-1.897-.131-.634-.437-1.218-.882-1.687-.47-.445-1.053-.75-1.687-.882-.633-.13-1.29-.083-1.897.14-.273-.587-.704-1.086-1.245-1.44S11.647 1.62 11 1.604c-.646.017-1.273.213-1.813.568s-.969.854-1.24 1.44c-.608-.223-1.267-.272-1.902-.14-.635.13-1.22.436-1.69.882-.445.47-.749 1.055-.878 1.688-.13.633-.08 1.29.144 1.896-.587.274-1.087.705-1.443 1.245-.356.54-.555 1.17-.574 1.817.02.647.218 1.276.574 1.817.356.54.856.972 1.443 1.245-.224.606-.274 1.263-.144 1.896.13.634.433 1.218.877 1.688.47.443 1.054.747 1.687.878.633.132 1.29.084 1.897-.136.274.586.705 1.084 1.246 1.439.54.354 1.17.551 1.816.569.647-.016 1.276-.213 1.817-.567s.972-.854 1.245-1.44c.604.239 1.266.296 1.903.164.636-.132 1.22-.447 1.68-.907.46-.46.776-1.044.908-1.681s.075-1.299-.165-1.903c.586-.274 1.084-.705 1.439-1.246.354-.54.551-1.17.569-1.816zM9.662 14.85l-3.429-3.428 1.293-1.302 2.072 2.072 4.4-4.794 1.347 1.246z"></path></g>
  4736. </svg>
  4737. `.replace(/\t|\n/g, '');
  4738. accountStatusNode.appendChild(iconVerified.firstChild);
  4739. }
  4740. return node;
  4741. }
  4742. }
  4743. async function displayToast(text,time = 2000){
  4744. try{
  4745. let node = document.createElement('div');
  4746. node.innerHTML = `
  4747. <div class="cta-base cta-backface-visibility-hidden cta-right-0px cta-position-fixed cta-left-0px cta-bottom-0px cta-pointer-events-none" cta-id="custom-alert">
  4748. <div class="cta-base cta-pointer-events-none">
  4749. <div class="cta-base cta-pointer-events-none">
  4750. <div class="cta-base cta-pointer-events-none cta-side-margin-auto cta-width-100per cta-max-width-600px">
  4751. <div role="alert" class="cta-base cta-align-items-center cta-background-color-twitterblue cta-flex-direction-row cta-justify-content-space-between cta-pointer-events-auto cta-align-self-center" style="transition-property: opacity; transition-duration: 170ms; transition-timing-function: cubic-bezier(0, 0, 1, 1); opacity: 1; padding: 12px; top: calc(env(safe-area-inset-bottom) - 53); border-radius: 4px; margin-bottom: 32px;" data-testid="toast">
  4752. <div dir="ltr" class="cta-text-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family cta-font-size cta-line-height cta-font-normal cta-flex-shrink-1" style="color: rgb(255, 255, 255); text-overflow: unset; padding-left: 12px; padding-right: 12px;">
  4753. <span class="cta-text2-css cta-min-width-0px cta-overflow-wrap-break-word cta-font-family" style="text-overflow: unset;">${text}</span>
  4754. </div>
  4755. <div aria-hidden="true" class="cta-base cta-flex-direction-row"></div>
  4756. </div>
  4757. </div>
  4758. </div>
  4759. </div>
  4760. </div>
  4761. `.replace(/\t|\n/g, '');
  4762. document.getElementById("react-root").appendChild(node.firstChild);
  4763. await sleep(time);
  4764. node.remove();
  4765. }catch(error){
  4766. console.error(error);
  4767. }finally{
  4768. let node = document.querySelector('[cta-id="custom-alert"]');
  4769. if(node)node.remove();
  4770. }
  4771. }
  4772. class requestObject_twitter_UnfavoriteTweet{
  4773. constructor(tweetID){
  4774. this.method = 'POST';
  4775. this.respType = 'json';
  4776. this.url = `https://${window.location.hostname}/i/api/graphql/ZYKSe-w7KEslx3JhSIk5LA/UnfavoriteTweet`;
  4777. this.body = `{"variables":{"tweet_id":"${tweetID}"},"queryId":"ZYKSe-w7KEslx3JhSIk5LA"}`;
  4778. this.headers = {
  4779. 'Content-Type': 'application/json',
  4780. 'User-agent': userAgent,
  4781. 'accept': '*/*',
  4782. 'Accept-Encoding': 'br, gzip, deflate',
  4783. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  4784. "x-csrf-token": GetCookie("ct0"),
  4785. 'Sec-Fetch-Site': 'same-origin',
  4786. };
  4787. this.package = null;
  4788. this.anonymous = false;
  4789. }
  4790. }
  4791. class requestObject_twitter_CreateRetweet{
  4792. constructor(tweetID){
  4793. this.method = 'POST';
  4794. this.respType = 'json';
  4795. this.url = `https://${window.location.hostname}/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet`;
  4796. this.body = `{"variables":{"tweet_id":"${tweetID}","dark_request":false},"queryId":"ojPdsZsimiJrUGLR1sjUtA"}`;
  4797. this.headers = {
  4798. 'Content-Type': 'application/json',
  4799. 'User-agent': userAgent,
  4800. 'accept': '*/*',
  4801. 'Accept-Encoding': 'br, gzip, deflate',
  4802. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  4803. "x-csrf-token": GetCookie("ct0"),
  4804. 'Sec-Fetch-Site': 'same-origin',
  4805. };
  4806. this.package = null;
  4807. this.anonymous = false;
  4808. }
  4809. }
  4810. class requestObject_twitter_DeleteRetweet{
  4811. constructor(tweetID){
  4812. this.method = 'POST';
  4813. this.respType = 'json';
  4814. this.url = `https://${window.location.hostname}/i/api/graphql/iQtK4dl5hBmXewYZuEOKVw/DeleteRetweet`;
  4815. this.body = `{"variables":{"source_tweet_id":"${tweetID}","dark_request":false},"queryId":"iQtK4dl5hBmXewYZuEOKVw"}`;
  4816. this.headers = {
  4817. 'Content-Type': 'application/json',
  4818. 'User-agent': userAgent,
  4819. 'accept': '*/*',
  4820. 'Accept-Encoding': 'br, gzip, deflate',
  4821. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  4822. "x-csrf-token": GetCookie("ct0"),
  4823. 'Sec-Fetch-Site': 'same-origin',
  4824. };
  4825. this.package = null;
  4826. this.anonymous = false;
  4827. }
  4828. }
  4829. class requestObject_twitter_CreateBookmark{
  4830. constructor(tweetID){
  4831. this.method = 'POST';
  4832. this.respType = 'json';
  4833. this.url = `https://${window.location.hostname}/i/api/graphql/aoDbu3RHznuiSkQ9aNM67Q/CreateBookmark`;
  4834. this.body = `{"variables":{"tweet_id":"${tweetID}"},"queryId":"aoDbu3RHznuiSkQ9aNM67Q"}`;
  4835. this.headers = {
  4836. 'Content-Type': 'application/json',
  4837. 'User-agent': userAgent,
  4838. 'accept': '*/*',
  4839. 'Accept-Encoding': 'br, gzip, deflate',
  4840. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  4841. "x-csrf-token": GetCookie("ct0"),
  4842. 'Sec-Fetch-Site': 'same-origin',
  4843. 'Sec-Fetch-Mode': 'navigate',
  4844. };
  4845. this.package = null;
  4846. this.anonymous = false;
  4847. }
  4848. }
  4849. class requestObject_twitter_DeleteBookmark{
  4850. constructor(tweetID){
  4851. this.method = 'POST';
  4852. this.respType = 'json';
  4853. this.url = `https://${window.location.hostname}/i/api/graphql/Wlmlj2-xzyS1GN3a6cj-mQ/DeleteBookmark`;
  4854. this.body = `{"variables":{"tweet_id":"${tweetID}"},"queryId":"Wlmlj2-xzyS1GN3a6cj-mQ"}`;
  4855. this.headers = {
  4856. 'Content-Type': 'application/json',
  4857. 'User-agent': userAgent,
  4858. 'accept': '*/*',
  4859. 'Accept-Encoding': 'br, gzip, deflate',
  4860. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  4861. "x-csrf-token": GetCookie("ct0"),
  4862. 'Sec-Fetch-Site': 'same-origin',
  4863. 'Sec-Fetch-Mode': 'navigate',
  4864. };
  4865. this.package = null;
  4866. this.anonymous = false;
  4867. }
  4868. }
  4869. function appendCtaCss(){
  4870. let style = document.createElement('style');
  4871. style.className = `cta-css`
  4872. style.textContent = `
  4873. .cta-base {
  4874. /*css-175oi2r*/
  4875. align-items: stretch;
  4876. background-color: rgba(0, 0, 0, 0.00);
  4877. border: 0 solid black;
  4878. box-sizing: border-box;
  4879. display: flex;
  4880. flex-basis: auto;
  4881. flex-direction: column;
  4882. flex-shrink: 0;
  4883. list-style: none;
  4884. margin: 0px;
  4885. min-height: 0px;
  4886. min-width: 0px;
  4887. padding: 0px;
  4888. position: relative;
  4889. text-decoration: none;
  4890. z-index: 0;
  4891. }
  4892. .cta-img-css {
  4893. /*css-9pa8cd*/
  4894. inset: 0px;
  4895. height: 100%;
  4896. opacity: 0;
  4897. position: absolute;
  4898. width: 100%;
  4899. z-index: -1;
  4900. }
  4901. .cta-text-css {
  4902. /*css-1rynq56*/
  4903. background-color: rgba(0, 0, 0, 0);
  4904. border: 0px solid black;
  4905. box-sizing: border-box;
  4906. color: rgb(0, 0, 0);
  4907. display: inline;
  4908. font: 14px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  4909. list-style: none;
  4910. margin: 0px;
  4911. padding: 0px;
  4912. text-align: inherit;
  4913. text-decoration: none;
  4914. white-space: pre-wrap;
  4915. overflow-wrap: break-word;
  4916. }
  4917. .cta-text2-css {
  4918. /*css-1qaijid*/
  4919. background-color: rgba(0, 0, 0, 0);
  4920. border: 0px solid black;
  4921. box-sizing: border-box;
  4922. color: inherit;
  4923. display: inline;
  4924. font: inherit;
  4925. list-style: none;
  4926. margin: 0px;
  4927. padding: 0px;
  4928. text-align: inherit;
  4929. text-decoration: none;
  4930. white-space: inherit;
  4931. overflow-wrap: break-word;
  4932. }
  4933. .cta-flex-direction-row {
  4934. /*r-18u37iz*/
  4935. flex-direction: row;
  4936. }
  4937. .cta-overflow-hidden {
  4938. /*r-1udh08x*/
  4939. overflow-x: hidden;
  4940. overflow-y: hidden;
  4941. }
  4942. .cta-overflow-visible {
  4943. /*r-bztko3*/
  4944. overflow-x: visible;
  4945. overflow-y: visible;
  4946. }
  4947. .cta-padding-left {
  4948. /*r-1qhn6m8*/
  4949. padding-left: calc(2.678%);
  4950. }
  4951. .cta-padding-bottom {
  4952. /*r-kzbkwu*/
  4953. padding-bottom: 12px;
  4954. }
  4955. .cta-padding-right {
  4956. /*r-i023vh*/
  4957. padding-right: calc(2.678%);
  4958. }
  4959. .cta-transition-duration {
  4960. /*r-o7ynqc*/
  4961. transition-duration: 0.2s;
  4962. }
  4963. .cta-transition-property {
  4964. /*r-6416eg*/
  4965. -moz-transition-property: background-color, box-shadow;
  4966. -webkit-transition-property: background-color, box-shadow;
  4967. transition-property: background-color, box-shadow;
  4968. }
  4969. .cta-outline-style-none {
  4970. /*r-1ny4l3l*/
  4971. outline-style: none;
  4972. }
  4973. .cta-cursor-pointer {
  4974. /*r-1loqt21*/
  4975. cursor: pointer;
  4976. }
  4977. .cta-flex-direction-column {
  4978. /*r-eqz5dr*/
  4979. flex-direction: column;
  4980. }
  4981. .cta-flex-grow-0 {
  4982. /*r-18kxxzh*/
  4983. flex-grow: 0;
  4984. }
  4985. .cta-flex-grow-1 {
  4986. /*r-16y2uox*/
  4987. flex-grow: 1;
  4988. }
  4989. .cta-flex-shrink-1 {
  4990. /*r-1wbh5a2*/
  4991. flex-shrink: 1;
  4992. }
  4993. .cta-flex-basis-0px {
  4994. /*r-1iusvr4*/
  4995. flex-basis: 0px;
  4996. }
  4997. .cta-padding-top {
  4998. /*r-ttdzmv*/
  4999. padding-top: calc(2.122%);
  5000. }
  5001. .cta-margin-right-big {
  5002. /*r-1b7u577*/
  5003. margin-right: calc(2.122%);
  5004. }
  5005. .cta-margin-right-small {
  5006. /*r-a5pmau*/
  5007. margin-right: calc(0.356%);
  5008. }
  5009. .cta-margin-top {
  5010. /*r-1s2bzr4*/
  5011. margin-top: 12px;
  5012. }
  5013. .cta-flex-basis-icon {
  5014. /*r-onrtq4*/
  5015. flex-basis: calc(7.07%);
  5016. }
  5017. .cta-align-items-center {
  5018. /*r-1awozwy*/
  5019. align-items: center;
  5020. }
  5021. .cta-width-100per {
  5022. /*r-13qz1uu*/
  5023. width: 100%;
  5024. }
  5025. .cta-display-block {
  5026. /*r-1adg3ll*/
  5027. display: block;
  5028. }
  5029. .cta-left-0px {
  5030. /*r-1d2f490*/
  5031. left: 0px;
  5032. }
  5033. .cta-top-0px {
  5034. /*r-ipm5af*/
  5035. top: 0px;
  5036. }
  5037. .cta-right-0px {
  5038. /*r-zchlnj*/
  5039. right: 0px;
  5040. }
  5041. .cta-bottom-0px {
  5042. /*r-1p0dtai*/
  5043. bottom: 0px;
  5044. }
  5045. .cta-height-100per {
  5046. /*r-1pi2tsx*/
  5047. height: 100%;
  5048. }
  5049. .cta-position-absolute {
  5050. /*r-u8s1d*/
  5051. position: absolute;
  5052. }
  5053. .cta-arrangement-center {
  5054. /*r-1wyvozj*/
  5055. /*r-1v2oles*/
  5056. /*r-desppf*/
  5057. left: 50%;
  5058. top: 50%;
  5059. transform: translateX(-50%) translateY(-50%);
  5060. }
  5061. .cta-icon-position-fix {
  5062. /*r-ggadg3*/
  5063. /*r-8jfcpp*/
  5064. left: calc(-0.356%);
  5065. top: calc(-0.356%);
  5066. }
  5067. .cta-shape-circle {
  5068. /*r-sdzlij*/
  5069. border-bottom-left-radius: 9999px;
  5070. border-bottom-right-radius: 9999px;
  5071. border-top-left-radius: 9999px;
  5072. border-top-right-radius: 9999px;
  5073. }
  5074. .cta-shape-square {
  5075. /*clip-path: url("#shape-square-rx-16");*/
  5076. border-bottom-left-radius: 4px;
  5077. border-bottom-right-radius: 4px;
  5078. border-top-left-radius: 4px;
  5079. border-top-right-radius: 4px;
  5080. }
  5081. .cta-pointer-events-none {
  5082. /*r-633pao*/
  5083. pointer-events: none !important;
  5084. }
  5085. .cta-flex-basis-auto {
  5086. /*r-1mlwlqe*/
  5087. flex-basis: auto;
  5088. }
  5089. .cta-z-index-0 {
  5090. /*r-417010*/
  5091. z-index: 0;
  5092. }
  5093. .cta-z-index--1 {
  5094. /*r-1wyyakw*/
  5095. z-index: -1;
  5096. }
  5097. .cta-display-inline-block {
  5098. /*r-4qtqp9*/
  5099. display: inline-block;
  5100. }
  5101. .cta-transparent-background {
  5102. /*r-1niwhzg*/
  5103. background-color: rgba(0, 0, 0, 0.00);
  5104. }
  5105. .cta-background-position-center {
  5106. /*r-vvn4in*/
  5107. background-position: center center;
  5108. }
  5109. .cta-background-no-repeat {
  5110. /*r-u6sd8q*/
  5111. background-repeat: no-repeat;
  5112. }
  5113. .cta-background-size-cover {
  5114. /*r-4gszlv*/
  5115. background-size: cover;
  5116. }
  5117. .cta-icon-box-shadow {
  5118. /*r-172uzmj*/
  5119. box-shadow: rgba(255, 255, 255, 0.03) 0px 0px 2px inset;
  5120. }
  5121. .cta-justify-content-center {
  5122. /*r-1777fci*/
  5123. justify-content: center;
  5124. }
  5125. .cta-justify-content-flex-start {
  5126. /*r-1h0z5md*/
  5127. justify-content: flex-start;
  5128. }
  5129. .cta-margin-bottom-small {
  5130. /*r-zl2h9q*/
  5131. margin-bottom: 2px;
  5132. }
  5133. .cta-margin-left-small {
  5134. /*r-9cviqr*/
  5135. margin-left: 2px;
  5136. }
  5137. .cta-align-items-start {
  5138. /*r-k4xj1c*/
  5139. align-items: start;
  5140. }
  5141. .cta-justify-content-space-between {
  5142. /*r-1wtj0ep*/
  5143. justify-content: space-between;
  5144. }
  5145. .cta-align-items-baseline {
  5146. /*r-1d09ksm*/
  5147. align-items: baseline;
  5148. }
  5149. .cta-max-width-100per {
  5150. /*r-dnmrzs*/
  5151. max-width: 100%;
  5152. }
  5153. .cta-min-width-0px {
  5154. /*r-bcqeeo*/
  5155. min-width: 0px;
  5156. }
  5157. .cta-overflow-wrap-break-word {
  5158. /*r-qvutc0*/
  5159. overflow-wrap: break-word;
  5160. }
  5161. .cta-font-family {
  5162. /*r-1tl8opc*/
  5163. font-family: "Segoe UI", Meiryo, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  5164. }
  5165. .cta-provisional-font-family {
  5166. /*r-37j5jr*/
  5167. font-family: "TwitterChirp", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  5168. }
  5169. .cta-font-size {
  5170. /*r-a023e6*/
  5171. font-size: 1em;
  5172. }
  5173. .cta-line-height {
  5174. /*r-rjixqe*/
  5175. line-height: 1.25em;
  5176. }
  5177. .cta-font-bold {
  5178. /*r-b88u0q*/
  5179. font-weight: 700;
  5180. }
  5181. .cta-font-normal {
  5182. /*r-16dba41*/
  5183. font-weight: 400;
  5184. }
  5185. .cta-display-flex {
  5186. /*r-6koalj*/
  5187. display: flex;
  5188. }
  5189. .cta-flex-shrink-0 {
  5190. /*r-1q142lx*/
  5191. flex-shrink: 0;
  5192. }
  5193. .cta-display-inline-flex {
  5194. /*r-xoduu5*/
  5195. display: inline-flex;
  5196. }
  5197. .cta-white-space-nowrap {
  5198. /*r-3s2u2q*/
  5199. white-space: nowrap;
  5200. }
  5201. .cta-fill-currentcolor {
  5202. /*r-yyyyoo*/
  5203. fill: currentcolor;
  5204. }
  5205. .cta-svg-height {
  5206. /*r-1xvli5t*/
  5207. height: 1.25em;
  5208. }
  5209. .cta-svg-width {
  5210. /*r-1hdv0qi*/
  5211. width: 1.25em;
  5212. }
  5213. .cta-svg-max-height {
  5214. /*r-f9ja8p*/
  5215. max-height: 1.25em;
  5216. }
  5217. .cta-svg-max-width {
  5218. /*r-og9te1*/
  5219. max-width: 1.25em;
  5220. }
  5221. .cta-svg-transition-property-color {
  5222. /*r-clp7b1*/
  5223. transition-property: color;
  5224. }
  5225. .cta-position-relative {
  5226. /*r-bnwqim*/
  5227. position: relative;
  5228. }
  5229. .cta-vertical-align-text-bottom {
  5230. /*r-1plcrui*/
  5231. vertical-align: text-bottom;
  5232. }
  5233. .cta-user-select-none {
  5234. /*r-lrvibr*/
  5235. user-select: none;
  5236. }
  5237. .cta-gap-4px {
  5238. /*r-9aw3ui*/
  5239. gap: 4px;
  5240. }
  5241. .cta-gap-8px {
  5242. /*r-1cmwbt1*/
  5243. gap: 8px;
  5244. }
  5245. .cta-gap-12px {
  5246. /*r-1ssbvtb*/
  5247. gap: 12px;
  5248. }
  5249. .cta-min-height-20px {
  5250. /*r-bt1l66*/
  5251. min-height: 20px;
  5252. }
  5253. .cta-margin--8px {
  5254. /*r-xf4iuw*/
  5255. margin: -8px;
  5256. }
  5257. .cta-box-orient-vertical {
  5258. /*r-8akbws*/
  5259. -moz-box-orient: vertical;
  5260. -webkit-box-orient: vertical;
  5261. }
  5262. .cta-font-family-inherit {
  5263. /*r-poiln3*/
  5264. font-family: inherit;
  5265. }
  5266. .cta-font-size-0px {
  5267. /*r-hiw28u*/
  5268. /*r-qvk6io*/
  5269. font-size: 0px;
  5270. line-height: 0px;
  5271. }
  5272. .cta-border {
  5273. /*r-18bvks7*/
  5274. /*r-1phboty*/
  5275. /*r-rs99b7*/
  5276. /*js制御*/
  5277. border-color: rgb(56, 68, 77);
  5278. border-style: solid;
  5279. overflow: hidden;
  5280. border-width: 1px;
  5281. }
  5282. .cta-border-radius-16px {
  5283. /*r-1867qdf*/
  5284. border-radius: 16px;
  5285. }
  5286. .cta-column-gap-4px {
  5287. /*r-1kbdv8c*/
  5288. column-gap: 4px;
  5289. }
  5290. .cta-max-width-600px {
  5291. /*r-1ye8kvj*/
  5292. max-width: 600px;
  5293. }
  5294. .cta-flex-1-1-0per {
  5295. /*r-13awgt0*/
  5296. flex: 1 1 0%;
  5297. }
  5298. .cta-engagement-text {
  5299. /*r-1pn2ns4*/
  5300. /*r-n6v787*/
  5301. /*r-1cwl3u0*/
  5302. /*r-1k6nrdp*/
  5303. padding-left: 4px;
  5304. padding-right: 4px;
  5305. line-height: 16px;
  5306. font-size: 13px;
  5307. min-width: calc(1em + 24px);
  5308. }
  5309. .cta-backface-visibility-hidden {
  5310. /*r-aqfbo4*/
  5311. backface-visibility: hidden;
  5312. }
  5313. .cta-position-fixed {
  5314. /*r-1xcajam*/
  5315. position: fixed;
  5316. }
  5317. .cta-pointer-events-none {
  5318. /*r-12vffkv*/
  5319. pointer-events: none !important;
  5320. }
  5321. .cta-background-color-twitterblue {
  5322. /*r-l5o3uw*/
  5323. background-color: rgb(29, 155, 240);
  5324. }
  5325. .cta-pointer-events-auto {
  5326. /*r-105ug2t*/
  5327. pointer-events: auto !important;
  5328. }
  5329. .cta-align-self-center {
  5330. /*r-1kihuf0*/
  5331. align-self: center;
  5332. }
  5333. .cta-side-margin-auto {
  5334. /*r-1jgb5lz*/
  5335. margin-left: auto;
  5336. margin-right: auto;
  5337. }
  5338. .cta-side-margin-12px {
  5339. /*r-1fz3rvf*/
  5340. margin-left: 12px;
  5341. margin-right: 12px;
  5342. }
  5343. .cta-font-feature-settings-ss01 {
  5344. /*r-1wvb978*/
  5345. font-feature-settings: "ss01";
  5346. }
  5347. .cta-side-padding-4px {
  5348. /*r-s1qlax*/
  5349. padding-left: 4px;
  5350. padding-right: 4px;
  5351. }
  5352. .cta-flex-wrap-wrap {
  5353. /*r-1w6e6rj*/
  5354. flex-wrap: wrap;
  5355. }
  5356. `.replace(/\t|\n/g, '');
  5357. document.head.appendChild(style);
  5358. }
  5359. appendCtaCss();
  5360.  
  5361. /////////////////////////////////////////////////////////////////////
  5362. /////////////////////////////////////////////////////////////////////
  5363. /////////////////////////////////////////////////////////////////////
  5364.  
  5365.  
  5366. class requestObject_twitter_api_v1_1{
  5367. constructor(ID,endpoints = "lookup"){
  5368. this.method = 'GET';
  5369. this.respType = 'json';
  5370. this.url = `https://api.twitter.com/1.1/statuses/${endpoints}.json?id=${ID}&tweet_mode=extended`;
  5371. this.body = null;
  5372. this.headers = {
  5373. "Content-Type": "application/json",
  5374. 'User-agent': userAgent,
  5375. 'accept': '*/*',
  5376. 'Accept-Encoding': 'br, gzip, deflate',
  5377. 'Referer': "https://twitter.com/",
  5378. 'Host': 'api.twitter.com',
  5379. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAAIK1zgAAAAAA2tUWuhGZ2JceoId5GwYWU5GspY4%3DUq7gzFoCZs1QfwGoVdvSac3IniczZEYXIcDyumCauIXpcAPorE',
  5380. 'x-csrf-token': GetCookie("ct0"),
  5381. };
  5382. this.package = null;
  5383. this.anonymous = false;
  5384. }
  5385. }
  5386. class requestObject_twitter_api_graphql{
  5387. constructor(ID){
  5388. this.method = 'GET';
  5389. this.respType = 'json';
  5390. this.url = `https://${window.location.hostname}/i/api/graphql/TuC3CinYecrqAyqccUyFhw/TweetDetail?variables=%7B%22focalTweetId%22%3A%22${ID}%22%2C%22referrer%22%3A%22home%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withArticleRichContent%22%3Atrue%2C%22withBirdwatchNotes%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22rweb_lists_timeline_redesign_enabled%22%3Atrue%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Atrue%2C%22responsive_web_twitter_article_tweet_consumption_enabled%22%3Atrue%2C%22tweet_awards_web_tipping_enabled%22%3Afalse%2C%22freedom_of_speech_not_reach_fetch_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Atrue%2C%22longform_notetweets_rich_text_read_enabled%22%3Atrue%2C%22longform_notetweets_inline_media_enabled%22%3Atrue%2C%22responsive_web_media_download_video_enabled%22%3Atrue%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D&fieldToggles=%7B%22withArticleRichContentState%22%3Atrue%7D`;
  5391. this.body = null;
  5392. this.headers = {
  5393. 'User-agent': userAgent,
  5394. 'accept': '*/*',
  5395. 'Accept-Encoding': 'br, gzip, deflate',
  5396. 'authorization': `Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA`,
  5397. 'x-csrf-token': GetCookie("ct0"),
  5398. };
  5399. this.package = null;
  5400. this.anonymous = false;
  5401. }
  5402. }
  5403. class requestObject_twitter_get_user_by_screenname{
  5404. constructor(ID){
  5405. this.method = 'GET';
  5406. this.respType = 'json';
  5407. this.url = `https://${window.location.hostname}/i/api/graphql/rePnxwe9LZ51nQ7Sn_xN_A/UserByScreenName?variables=%7B%22screen_name%22%3A%22${ID}%22%2C%22withSafetyModeUserFields%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Afalse%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Afalse%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Afalse%2C%22verified_phone_label_enabled%22%3Afalse%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Afalse%7D`;
  5408. this.body = null;
  5409. this.headers = {
  5410. "Content-Type": "application/json",
  5411. 'User-agent': userAgent,
  5412. 'accept': '*/*',
  5413. 'Referer': `https://${window.location.hostname}/`,
  5414. 'Accept-Encoding': 'br, gzip, deflate',
  5415. 'authorization': `Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA`,
  5416. 'x-csrf-token': GetCookie("ct0"),
  5417. };
  5418. this.package = null;
  5419. this.anonymous = false;
  5420. this.screen_name = ID;
  5421. }
  5422. }
  5423. class requestObject_twitter_get_user_by_screenname_1_1{
  5424. constructor(ID) {
  5425. this.method = 'GET';
  5426. this.respType = 'json';
  5427. this.url = `https://api.twitter.com/1.1/users/show.json?screen_name=${ID}`;
  5428. this.body = null;
  5429. this.headers = {
  5430. "Content-Type": "application/json",
  5431. 'User-agent': userAgent,
  5432. 'accept': '*/*',
  5433. 'Referer': "https://twitter.com/",
  5434. 'Accept-Encoding': 'br, gzip, deflate',
  5435. 'authorization': `Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA`,
  5436. 'x-csrf-token': GetCookie("ct0"),
  5437. };
  5438. this.package = null;
  5439. this.anonymous = false;
  5440. this.screen_name = ID;
  5441. }
  5442. }
  5443. class requestObject_twitter_time_line{
  5444. constructor(){
  5445. this.method = 'POST';
  5446. this.respType = 'json';
  5447. this.url = `https://${window.location.hostname}/i/api/graphql/HnVOsy-Rh_0Cuq06_z9lGA/HomeLatestTimeline`;
  5448. this.body = JSON.stringify({
  5449. "variables": {
  5450. "count": 100,
  5451. "includePromotedContent": false,
  5452. "latestControlAvailable": true,
  5453. "requestContext": "launch"
  5454. },
  5455. "features": {
  5456. "responsive_web_graphql_exclude_directive_enabled": true,
  5457. "verified_phone_label_enabled": false,
  5458. "responsive_web_home_pinned_timelines_enabled": true,
  5459. "creator_subscriptions_tweet_preview_api_enabled": true,
  5460. "responsive_web_graphql_timeline_navigation_enabled": true,
  5461. "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
  5462. "tweetypie_unmention_optimization_enabled": true,
  5463. "responsive_web_edit_tweet_api_enabled": true,
  5464. "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true,
  5465. "view_counts_everywhere_api_enabled": true,
  5466. "longform_notetweets_consumption_enabled": true,
  5467. "responsive_web_twitter_article_tweet_consumption_enabled": false,
  5468. "tweet_awards_web_tipping_enabled": false,
  5469. "freedom_of_speech_not_reach_fetch_enabled": true,
  5470. "standardized_nudges_misinfo": true,
  5471. "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
  5472. "longform_notetweets_rich_text_read_enabled": true,
  5473. "longform_notetweets_inline_media_enabled": true,
  5474. "responsive_web_media_download_video_enabled": true,
  5475. "responsive_web_enhance_cards_enabled": false
  5476. },
  5477. "queryId": "HnVOsy-Rh_0Cuq06_z9lGA"
  5478. });
  5479. this.headers = {
  5480. "Content-Type": "application/json",
  5481. 'User-agent': userAgent,
  5482. 'accept': '*/*',
  5483. 'Referer': `https://${window.location.hostname}/`,
  5484. 'Accept-Encoding': 'br, gzip, deflate',
  5485. 'authorization': `Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA`,
  5486. 'x-csrf-token': GetCookie("ct0"),
  5487. };
  5488. this.package = null;
  5489. this.anonymous = false;
  5490. }
  5491. }
  5492. class requestObject_twitter_time_line_forYou{
  5493. constructor(){
  5494. this.method = 'POST';
  5495. this.respType = 'json';
  5496. this.url = `https://${window.location.hostname}/i/api/graphql/-8TWbLqVU1ROq-eeErVc2w/HomeTimeline`;
  5497. this.body = JSON.stringify({
  5498. "variables": {
  5499. "count": 100,
  5500. "includePromotedContent": false,
  5501. "latestControlAvailable": true,
  5502. "requestContext": "launch",
  5503. "withCommunity": true,
  5504. },
  5505. "features": {
  5506. "responsive_web_graphql_exclude_directive_enabled": true,
  5507. "verified_phone_label_enabled": false,
  5508. "responsive_web_home_pinned_timelines_enabled": true,
  5509. "creator_subscriptions_tweet_preview_api_enabled": true,
  5510. "responsive_web_graphql_timeline_navigation_enabled": true,
  5511. "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
  5512. "tweetypie_unmention_optimization_enabled": true,
  5513. "responsive_web_edit_tweet_api_enabled": true,
  5514. "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true,
  5515. "view_counts_everywhere_api_enabled": true,
  5516. "longform_notetweets_consumption_enabled": true,
  5517. "responsive_web_twitter_article_tweet_consumption_enabled": false,
  5518. "tweet_awards_web_tipping_enabled": false,
  5519. "freedom_of_speech_not_reach_fetch_enabled": true,
  5520. "standardized_nudges_misinfo": true,
  5521. "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
  5522. "longform_notetweets_rich_text_read_enabled": true,
  5523. "longform_notetweets_inline_media_enabled": true,
  5524. "responsive_web_media_download_video_enabled": false,
  5525. "responsive_web_enhance_cards_enabled": false
  5526. },
  5527. "queryId": "-8TWbLqVU1ROq-eeErVc2w"
  5528. });
  5529. this.headers = {
  5530. "Content-Type": "application/json",
  5531. 'User-agent': userAgent,
  5532. 'accept': '*/*',
  5533. 'Referer': `https://${window.location.hostname}/`,
  5534. 'Accept-Encoding': 'br, gzip, deflate',
  5535. 'authorization': `Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA`,
  5536. 'x-csrf-token': GetCookie("ct0"),
  5537. };
  5538. this.package = null;
  5539. this.anonymous = false;
  5540. }
  5541. }
  5542.  
  5543. class requestObject_twitter_FavoriteTweet{
  5544. constructor(URL){
  5545. this.method = 'POST';
  5546. this.respType = 'json';
  5547. this.url = `https://${window.location.hostname}/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet`;
  5548. this.body = `{"variables":{"tweet_id":"${URL.split('/').pop()}"},"queryId":"lI07N6Otwv1PhnEgXILM7A"}`;
  5549. this.headers = {
  5550. 'Content-Type': 'application/json',
  5551. 'User-agent': userAgent,
  5552. 'accept': '*/*',
  5553. 'Referer': URL,
  5554. 'Accept-Encoding': 'br, gzip, deflate',
  5555. 'Origin': `https://${window.location.hostname}`,
  5556. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  5557. "x-csrf-token": GetCookie("ct0"),
  5558. 'Sec-Fetch-Site': 'same-origin',
  5559. 'Sec-Fetch-Mode': 'navigate',
  5560. };
  5561. this.package = null;
  5562. this.anonymous = false;
  5563. }
  5564. }
  5565. class requestObject_url_expand{
  5566. constructor(URL){
  5567. this.method = 'POST';
  5568. this.respType = 'text';
  5569. this.url = `https://geek-website.com/tool/shortlink_open/request.php`;
  5570. this.body = `shortlink=${encodeURIComponent(URL)}`;
  5571. this.headers = {
  5572. "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
  5573. 'User-agent': userAgent,
  5574. "Accept": "text/plain, */*; q=0.01",
  5575. 'Accept-Encoding': 'br, gzip, deflate',
  5576. 'Referer': "https://geek-website.com/tool/shortlink_open/",
  5577. 'Host': 'geek-website.com',
  5578. "Sec-Fetch-Dest": "empty",
  5579. "Sec-Fetch-Mode": "cors",
  5580. "Sec-Fetch-Site": "same-origin"
  5581. };
  5582. this.package = null;
  5583. this.anonymous = true;
  5584. }
  5585. }
  5586. class requestObject_skeb{
  5587. constructor(URL,skeb_URL){
  5588. this.method = 'GET';
  5589. this.respType = 'json';
  5590. this.url = `${URL}`;
  5591. this.body = null;
  5592. this.headers = {
  5593. 'User-agent': userAgent,
  5594. 'Referer': skeb_URL,
  5595. 'Alt-Used': 'skeb.jp',
  5596. 'Authorization': 'Bearer null',
  5597. "Sec-Fetch-Mode": "cors",
  5598. "Sec-Fetch-Site": "same-site",
  5599. 'Accept-Encoding': 'br, gzip, deflate',
  5600. };
  5601. }
  5602. }
  5603. class requestObject_fanbox{
  5604. constructor(URL,fanbox_URL){
  5605. this.method = 'GET';
  5606. this.respType = 'json';
  5607. this.url = `${URL}`;
  5608. this.body = null;
  5609. this.headers = {
  5610. 'User-agent': userAgent,
  5611. 'origin': fanbox_URL,
  5612. "Sec-Fetch-Mode": "cors",
  5613. "Sec-Fetch-Site": "same-site",
  5614. 'Accept-Encoding': 'br, gzip, deflate',
  5615. 'Host': 'api.fanbox.cc',
  5616. };
  5617. }
  5618. }
  5619. class sendObject_to_discord_webhook{
  5620. constructor(webhook,sendEmbeds){
  5621. this.method = 'POST';
  5622. this.respType = 'json';
  5623. this.url = "https://discord.com/api/webhooks/" + atob(webhook);
  5624. this.headers = {
  5625. };
  5626. this.package = null;
  5627. this.anonymous = true;
  5628. this.body = sendEmbeds;
  5629. }
  5630. }
  5631. class requestObject_binary_data{
  5632. constructor(URL,addtional_cookie = undefined){
  5633. this.method = 'GET';
  5634. this.respType = 'blob';
  5635. this.url = `${URL}`;
  5636. this.body = null;
  5637. this.encoding = null;
  5638. this.headers = {
  5639. "Content-Type": "*/*",
  5640. 'User-agent': navigator.userAgent || navigator.vendor || window.opera,
  5641. 'accept': '*/*',
  5642. 'Accept-Encoding': 'br, gzip, deflate',
  5643. 'Referer': URL,
  5644. "Sec-Fetch-Mode": "navigate",
  5645. 'cookie': `${addtional_cookie}`,
  5646. 'Range': 'bytes=0-24117249'
  5647. };
  5648. this.package = null;
  5649. }
  5650. }
  5651. class requestObject_binary_head{
  5652. constructor(URL, addtional_cookie = undefined) {
  5653. this.method = 'HEAD';
  5654. this.url = `${URL}`;
  5655. this.body = null;
  5656. this.encoding = null;
  5657. this.headers = {
  5658. "Content-Type": "json,*/*",
  5659. 'User-agent': navigator.userAgent || navigator.vendor || window.opera,
  5660. 'accept': '*/*',
  5661. 'Accept-Encoding': 'br, gzip, deflate',
  5662. 'Referer': URL,
  5663. "Sec-Fetch-Mode": "navigate",
  5664. 'cookie': `${addtional_cookie}`
  5665. };
  5666. this.package = null;
  5667. }
  5668. }
  5669. class requestObject{
  5670. constructor(URL, method = 'GET', type = "", cookie = "", anonymous = false){
  5671. this.method = method;
  5672. this.respType = type;
  5673. this.url = URL;
  5674. this.headers = {
  5675. "Content-Type": "*/*",
  5676. 'Accept-Encoding': 'br, gzip, deflate',
  5677. 'User-agent': userAgent,
  5678. 'accept': '*/*',
  5679. 'Referer': URL,
  5680. "Sec-Fetch-Mode": "navigate",
  5681. "Sec-Fetch-Dest": "empty",
  5682. "Sec-Fetch-Mode": "cors",
  5683. "Sec-Fetch-Site": "same-origin",
  5684. 'cookie': `${cookie}`
  5685. };
  5686. this.package = null;
  5687. this.anonymous = anonymous;
  5688. }
  5689. }
  5690. class requestObject_twitter_get_user_media{
  5691. constructor(url,variables){
  5692. this.method = 'GET';
  5693. this.respType = 'json';
  5694. this.url = `${url}?variables=${encodeURIComponent(JSON.stringify(variables))}&features=${encodeURIComponent(JSON.stringify({
  5695. "responsive_web_graphql_exclude_directive_enabled": true,
  5696. "verified_phone_label_enabled": false,
  5697. "responsive_web_home_pinned_timelines_enabled": true,
  5698. "creator_subscriptions_tweet_preview_api_enabled": true,
  5699. "responsive_web_graphql_timeline_navigation_enabled": true,
  5700. "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
  5701. "c9s_tweet_anatomy_moderator_badge_enabled": true,
  5702. "tweetypie_unmention_optimization_enabled": true,
  5703. "responsive_web_edit_tweet_api_enabled": true,
  5704. "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true,
  5705. "view_counts_everywhere_api_enabled": true,
  5706. "longform_notetweets_consumption_enabled": true,
  5707. "responsive_web_twitter_article_tweet_consumption_enabled": false,
  5708. "tweet_awards_web_tipping_enabled": false,
  5709. "freedom_of_speech_not_reach_fetch_enabled": true,
  5710. "standardized_nudges_misinfo": true,
  5711. "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
  5712. "longform_notetweets_rich_text_read_enabled": true,
  5713. "longform_notetweets_inline_media_enabled": true,
  5714. "responsive_web_media_download_video_enabled": false,
  5715. "responsive_web_enhance_cards_enabled": false
  5716. }))}`;
  5717. this.body = null;
  5718. this.headers = {
  5719. 'User-agent': userAgent,
  5720. 'accept': '*/*',
  5721. 'Accept-Encoding': 'br, gzip, deflate',
  5722. 'authorization': `Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA`,
  5723. 'x-csrf-token': GetCookie("ct0"),
  5724. };
  5725. this.package = null;
  5726. this.anonymous = false;
  5727. }
  5728. }
  5729. class requestObject_twitter_get_search_media{
  5730. constructor(url,variables){
  5731. this.method = 'GET';
  5732. this.respType = 'json';
  5733. this.url = `${url}?variables=${encodeURIComponent(JSON.stringify(variables))}&features=${encodeURIComponent(JSON.stringify({
  5734. "responsive_web_graphql_exclude_directive_enabled": true,
  5735. "verified_phone_label_enabled": false,
  5736. "creator_subscriptions_tweet_preview_api_enabled": true,
  5737. "responsive_web_graphql_timeline_navigation_enabled": true,
  5738. "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
  5739. "c9s_tweet_anatomy_moderator_badge_enabled": true,
  5740. "tweetypie_unmention_optimization_enabled": true,
  5741. "responsive_web_edit_tweet_api_enabled": true,
  5742. "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true,
  5743. "view_counts_everywhere_api_enabled": true,
  5744. "longform_notetweets_consumption_enabled": true,
  5745. "responsive_web_twitter_article_tweet_consumption_enabled": false,
  5746. "tweet_awards_web_tipping_enabled": false,
  5747. "freedom_of_speech_not_reach_fetch_enabled": true,
  5748. "standardized_nudges_misinfo": true,
  5749. "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
  5750. "rweb_video_timestamps_enabled": true,
  5751. "longform_notetweets_rich_text_read_enabled": true,
  5752. "longform_notetweets_inline_media_enabled": true,
  5753. "responsive_web_media_download_video_enabled": false,
  5754. "responsive_web_enhance_cards_enabled": false
  5755. }))}`;
  5756. this.body = null;
  5757. this.headers = {
  5758. 'User-agent': userAgent,
  5759. 'accept': '*/*',
  5760. 'Accept-Encoding': 'br, gzip, deflate',
  5761. 'authorization': `Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA`,
  5762. 'x-csrf-token': GetCookie("ct0"),
  5763. };
  5764. this.package = null;
  5765. this.anonymous = false;
  5766. }
  5767. }
  5768. class requestObject_twitter_api_v1_1_favorites{
  5769. constructor(screen_name,max_id = null){
  5770. this.method = 'GET';
  5771. this.respType = 'json';
  5772. this.url = `https://api.${window.location.hostname}/1.1/favorites/list.json?count=200&screen_name=${screen_name}${max_id? `&max_id=${max_id}`: ''}`;
  5773. this.body = null;
  5774. this.headers = {
  5775. "Content-Type": "application/json",
  5776. 'User-agent': userAgent,
  5777. 'accept': '*/*',
  5778. 'Accept-Encoding': 'br, gzip, deflate',
  5779. 'Referer': `https://${window.location.hostname}/`,
  5780. 'Host': `api.${window.location.hostname}`,
  5781. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAAIK1zgAAAAAA2tUWuhGZ2JceoId5GwYWU5GspY4%3DUq7gzFoCZs1QfwGoVdvSac3IniczZEYXIcDyumCauIXpcAPorE',
  5782. 'x-csrf-token': GetCookie("ct0"),
  5783. };
  5784. this.package = null;
  5785. this.anonymous = false;
  5786. }
  5787. }
  5788. async function test(){
  5789. }
  5790. async function isFirstTime(){
  5791. if(!localStorage.getItem('Make_Twitter_little_useful')){
  5792. const settings = '{"Make_Twitter_little_useful_script_SettingsData":{"Make_Twitter_little_useful":{"featuresToggle":{"webhook_brings_tweets_to_discord":false,"Engagement_Restorer":true,"sneakilyFavorite":false,"Hello_tweet_where_are_you_from":true,"Note_Tweet_expander":true,"Show_me_your_Pixiv":false,"showFollowers":true,"hideAnalytics":false,"quickShareTweetLink":false,"Show_all_Medias":false,"show_me_big_pics":false},"lang":"ja"},"webhook_brings_tweets_to_discord":{"data":[],"downloadVideo":null,"defaultWebhook":"","displayMethod":"method1","lang":"ja"},"Hello_tweet_where_are_you_from":{},"Show_me_your_Pixiv":{"showMeYourPixivCollectionMethod":1},"Note_Tweet_expander":{},"sneakilyFavorite":{},"Engagement_Restorer":{},"Show_all_Medias":{"displayMethod":null,"removeBlur":false,"onlyRemoveBlur":false}}}';
  5793. const importedData = JSON.parse(settings);
  5794. if(!importedData || !importedData.Make_Twitter_little_useful_script_SettingsData){
  5795. throw new Error("Invalid data format");
  5796. }
  5797. const importedSettings = importedData.Make_Twitter_little_useful_script_SettingsData;
  5798. for(let key in importedSettings){
  5799. localStorage.setItem(key, JSON.stringify(importedSettings[key]));
  5800. }
  5801. storedSettings = {
  5802. 'Make_Twitter_little_useful': JSON.parse(localStorage.getItem('Make_Twitter_little_useful') || '{}'),
  5803. 'webhook_brings_tweets_to_discord': JSON.parse(localStorage.getItem('webhook_brings_tweets_to_discord') || '{}'),
  5804. 'Hello_tweet_where_are_you_from': JSON.parse(localStorage.getItem('Hello_tweet_where_are_you_from') || '{}'),
  5805. 'Show_me_your_Pixiv': JSON.parse(localStorage.getItem('Show_me_your_Pixiv') || '{}'),
  5806. 'Note_Tweet_expander': JSON.parse(localStorage.getItem('Note_Tweet_expander') || '{}'),
  5807. 'sneakilyFavorite': JSON.parse(localStorage.getItem('sneakilyFavorite') || '{}'),
  5808. 'Engagement_Restorer': JSON.parse(localStorage.getItem('Engagement_Restorer') || '{}'),
  5809. 'Show_all_Medias': JSON.parse(localStorage.getItem('Show_all_Medias') || '{}'),
  5810. }
  5811. openSettings();
  5812. }
  5813. if(!(await getFromIndexedDB('Show_me_your_Pixiv','pixiv_link_collection_dataBase'))){
  5814. const downloadData = JSON.parse((await request(new requestObject('https://dl.dropboxusercontent.com/s/stvehlbre5gir6xtaxgz8/screenName2PixivID.json?rlkey=0vqz5kb333fehmcd1xtftj9b5'))).response);
  5815. scriptDataStore.Show_me_your_Pixiv_dataBase = downloadData;
  5816. await saveToIndexedDB('Show_me_your_Pixiv','pixiv_link_collection_dataBase',downloadData);
  5817. }
  5818. }
  5819. await isFirstTime();
  5820. const reactRoot = document.getElementById("react-root");
  5821. locationChange();
  5822. main();
  5823. //fetchAndProcessTwitterApi("TL");
  5824. if(currentUrl.match(/https?:\/\/[\w]{1,}\.com\/[\w]*\/status\/[0-9]*/))fetchAndProcessTwitterApi("graphQL",extractTweetId(currentUrl));
  5825. window.addEventListener("scroll", update);
  5826. try{
  5827. addEventToScrollSnapSwipeableList();
  5828. addEventToHomeButton();
  5829. }catch{}
  5830. class requestObjectBinaryData{
  5831. constructor(URL,addtional_cookie = undefined){
  5832. this.method = 'GET';
  5833. this.respType = 'blob';
  5834. this.url = `${URL}`;
  5835. this.body = null;
  5836. this.encoding = null;
  5837. this.headers = {
  5838. "Content-Type": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*",
  5839. 'User-agent': navigator.userAgent || navigator.vendor || window.opera,
  5840. 'Accept-Encoding': 'br, gzip, deflate, zstd',
  5841. 'accept': '*/*',
  5842. 'Referer': URL,
  5843. "Sec-Fetch-Mode": "navigate",
  5844. 'cookie': `${addtional_cookie}`
  5845. };
  5846. this.package = null;
  5847. }
  5848. }
  5849. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址