Twitter Media Eagle Support

Save Video/Photo to Ealge by One-Click.

  1. // ==UserScript==
  2. // @name Twitter Media Eagle Support
  3. // @name:ja Twitter Media Support
  4. // @name:zh-tw Twitter 媒體Eagle保存
  5. // @description Save Video/Photo to Ealge by One-Click.
  6. // @description:ja ワンクリックでビデオ/写真をEalgeに保存します。
  7. // @description:zh-tw 一鍵保存影片/圖片到Eagle
  8. // @version 1.0.1
  9. // @author AMANE
  10. // @namespace none
  11. // @match https://twitter.com/*
  12. // @match https://x.com/*
  13. // @match https://mobile.twitter.com/*
  14. // @grant GM_registerMenuCommand
  15. // @grant GM_setValue
  16. // @grant GM_getValue
  17. // @grant GM_xmlhttpRequest
  18. // @compatible Chrome
  19. // @compatible Firefox
  20. // @license MIT
  21. // ==/UserScript==
  22. // Forked from https://gf.qytechs.cn/zh-TW/scripts/501681-twitter-x-media-downloader
  23.  
  24. const filename = 'twitter_{user-name}(@{user-id})_{date-time}_{status-id}_{file-type}';
  25.  
  26. const TMD = (function () {
  27. let lang, host, history, show_sensitive, is_tweetdeck;
  28. return {
  29. init: async function () {
  30. GM_registerMenuCommand((this.language[navigator.language] || this.language.en).settings, this.settings);
  31. lang = this.language[document.querySelector('html').lang] || this.language.en;
  32.  
  33. host = location.hostname;
  34. is_tweetdeck = host.indexOf('tweetdeck') >= 0;
  35. history = this.storage_obsolete();
  36. if (history.length) {
  37. this.storage(history);
  38. this.storage_obsolete(true);
  39. } else history = await this.storage();
  40. show_sensitive = GM_getValue('show_sensitive', false);
  41. document.head.insertAdjacentHTML('beforeend', '<style>' + this.css + (show_sensitive ? this.css_ss : '') + '</style>');
  42. let observer = new MutationObserver(ms => ms.forEach(m => m.addedNodes.forEach(node => this.detect(node))));
  43. observer.observe(document.body, {childList: true, subtree: true});
  44. },
  45. detect: function(node) {
  46. let article = node.tagName == 'ARTICLE' && node || node.tagName == 'DIV' && (node.querySelector('article') || node.closest('article'));
  47. if (article) this.addButtonTo(article);
  48. let listitems = node.tagName == 'LI' && node.getAttribute('role') == 'listitem' && [node] || node.tagName == 'DIV' && node.querySelectorAll('li[role="listitem"]');
  49. if (listitems) this.addButtonToMedia(listitems);
  50. },
  51. addButtonTo: function (article) {
  52. if (article.dataset.detected) return;
  53. article.dataset.detected = 'true';
  54. let media_selector = [
  55. 'a[href*="/photo/1"]',
  56. 'div[role="progressbar"]',
  57. 'button[data-testid="playButton"]',
  58. 'a[href="/settings/content_you_see"]', //hidden content
  59. 'div.media-image-container', // for tweetdeck
  60. 'div.media-preview-container', // for tweetdeck
  61. 'div[aria-labelledby]>div:first-child>div[role="button"][tabindex="0"]' //for audio (experimental)
  62. ];
  63. let media = article.querySelector(media_selector.join(','));
  64. if (media) {
  65. let status_id = article.querySelector('a[href*="/status/"]').href.split('/status/').pop().split('/').shift();
  66. let btn_group = article.querySelector('div[role="group"]:last-of-type, ul.tweet-actions, ul.tweet-detail-actions');
  67. let btn_share = Array.from(btn_group.querySelectorAll(':scope>div>div, li.tweet-action-item>a, li.tweet-detail-action-item>a')).pop().parentNode;
  68. let btn_down = btn_share.cloneNode(true);
  69. btn_down.querySelector('button').removeAttribute('disabled');
  70. if (is_tweetdeck) {
  71. btn_down.firstElementChild.innerHTML = '<svg viewBox="0 0 24 24" style="width: 18px; height: 18px;">' + this.svg + '</svg>';
  72. btn_down.firstElementChild.removeAttribute('rel');
  73. btn_down.classList.replace("pull-left", "pull-right");
  74. } else {
  75. btn_down.querySelector('svg').innerHTML = this.svg;
  76. }
  77. let is_exist = history.indexOf(status_id) >= 0;
  78. this.status(btn_down, 'tmd-down');
  79. this.status(btn_down, is_exist ? 'completed' : 'download', is_exist ? lang.completed : lang.download);
  80. btn_group.insertBefore(btn_down, btn_share.nextSibling);
  81. article.onkeydown = (e) => this.keydown(e, btn_down, status_id, is_exist);
  82. btn_down.onclick = () => this.click(btn_down, status_id, is_exist);
  83. if (show_sensitive) {
  84. let btn_show = article.querySelector('div[aria-labelledby] div[role="button"][tabindex="0"]:not([data-testid]) > div[dir] > span > span');
  85. if (btn_show) btn_show.click();
  86. }
  87. }
  88. let imgs = article.querySelectorAll('a[href*="/photo/"]');
  89. if (imgs.length > 1) {
  90. let status_id = article.querySelector('a[href*="/status/"]').href.split('/status/').pop().split('/').shift();
  91. let btn_group = article.querySelector('div[role="group"]:last-of-type');
  92. let btn_share = Array.from(btn_group.querySelectorAll(':scope>div>div')).pop().parentNode;
  93. imgs.forEach(img => {
  94. let index = img.href.split('/status/').pop().split('/').pop();
  95. let is_exist = history.indexOf(status_id) >= 0;
  96. let btn_down = document.createElement('div');
  97. btn_down.innerHTML = '<div><div><svg viewBox="0 0 24 24" style="width: 18px; height: 18px;">' + this.svg + '</svg></div></div>';
  98. btn_down.classList.add('tmd-down', 'tmd-img');
  99. this.status(btn_down, 'download');
  100. img.parentNode.appendChild(btn_down);
  101. btn_down.onclick = e => {
  102. e.preventDefault();
  103. this.click(btn_down, status_id, is_exist, index);
  104. }
  105. });
  106. }
  107. },
  108. keydown: async function (event, btn, status_id, is_exist, index) {
  109. if (event.key === ";") this.click(btn, status_id, is_exist, index);
  110. },
  111. addButtonToMedia: function(listitems) {
  112. listitems.forEach(li => {
  113. if (li.dataset.detected) return;
  114. li.dataset.detected = 'true';
  115. let status_id = li.querySelector('a[href*="/status/"]').href.split('/status/').pop().split('/').shift();
  116. let is_exist = history.indexOf(status_id) >= 0;
  117. let btn_down = document.createElement('div');
  118. btn_down.innerHTML = '<div><div><svg viewBox="0 0 24 24" style="width: 18px; height: 18px;">' + this.svg + '</svg></div></div>';
  119. btn_down.classList.add('tmd-down', 'tmd-media');
  120. this.status(btn_down, is_exist ? 'completed' : 'download', is_exist ? lang.completed : lang.download);
  121. li.appendChild(btn_down);
  122. btn_down.onclick = () => this.click(btn_down, status_id, is_exist);
  123. });
  124. },
  125. click: async function (btn, status_id, is_exist, index) {
  126. if (btn.classList.contains('loading')) return;
  127. this.status(btn, 'loading');
  128. let out = (await GM_getValue('filename', filename)).split('\n').join('');
  129. let save_history = await GM_getValue('save_history', true);
  130. let json = await this.fetchJson(status_id);
  131. let tweet = json.legacy;
  132. let user = json.core.user_results.result.legacy;
  133. let invalid_chars = {'\\': '\', '\/': '/', '\|': '|', '<': '<', '>': '>', ':': ':', '*': '*', '?': '?', '"': '"', '\u200b': '', '\u200c': '', '\u200d': '', '\u2060': '', '\ufeff': '', '🔞': ''};
  134. let datetime = out.match(/{date-time(-local)?:[^{}]+}/) ? out.match(/{date-time(?:-local)?:([^{}]+)}/)[1].replace(/[\\/|<>*?:"]/g, v => invalid_chars[v]) : 'YYYYMMDD-hhmmss';
  135. let info = {};
  136. info['status-id'] = status_id;
  137. info['user-name'] = user.name.replace(/([\\/|*?:"]|[\u200b-\u200d\u2060\ufeff]|🔞)/g, v => invalid_chars[v]);
  138. info['user-id'] = user.screen_name;
  139. info['date-time'] = this.formatDate(tweet.created_at, datetime);
  140. info['date-time-local'] = this.formatDate(tweet.created_at, datetime, true);
  141. info['full-text'] = tweet.full_text.split('\n').join(' ').replace(/\s*https:\/\/t\.co\/\w+/g, '').replace(/[\\/|<>*?:"]|[\u200b-\u200d\u2060\ufeff]/g, v => invalid_chars[v]);
  142. let medias = tweet.extended_entities && tweet.extended_entities.media;
  143. if (index) medias = [medias[index - 1]];
  144. if (medias.length > 0) {
  145. let tasks = medias.length;
  146. let tasks_result = [];
  147. medias.forEach((media, i) => {
  148. info.url = media.type == 'photo' ? media.media_url_https + ':orig' : media.video_info.variants.filter(n => n.content_type == 'video/mp4').sort((a, b) => b.bitrate - a.bitrate)[0].url;
  149. info.file = info.url.split('/').pop().split(/[:?]/).shift();
  150. info['file-name'] = info.file.split('.').shift();
  151. info['file-ext'] = info.file.split('.').pop();
  152. info['file-type'] = media.type.replace('animated_', '');
  153. info.out = (out.replace(/\.?{file-ext}/, '') + ((medias.length > 1 || index) && !out.match('{file-name}') ? '-' + (index ? index - 1 : i) : '') + '.{file-ext}').replace(/{([^{}:]+)(:[^{}]+)?}/g, (match, name) => info[name]);
  154. this.downloader.add({
  155. url: info.url,
  156. name: info.out,
  157. onload: () => {
  158. tasks -= 1;
  159. tasks_result.push(((medias.length > 1 || index) ? (index ? index : i + 1) + ': ' : '') + lang.completed);
  160. this.status(btn, null, tasks_result.sort().join('\n'));
  161. if (tasks === 0) {
  162. this.status(btn, 'completed', lang.completed);
  163. if (save_history && !is_exist) {
  164. history.push(status_id);
  165. this.storage(status_id);
  166. }
  167. }
  168. },
  169. onerror: result => {
  170. tasks = -1;
  171. tasks_result.push((medias.length > 1 ? i + 1 + ': ' : '') + result.details.current);
  172. this.status(btn, 'failed', tasks_result.sort().join('\n'));
  173. }
  174. });
  175. });
  176. } else {
  177. this.status(btn, 'failed', 'MEDIA_NOT_FOUND');
  178. }
  179. },
  180. status: function (btn, css, title, style) {
  181. if (css) {
  182. btn.classList.remove('download', 'completed', 'loading', 'failed');
  183. btn.classList.add(css);
  184. }
  185. if (title) btn.title = title;
  186. if (style) btn.style.cssText = style;
  187. },
  188. settings: async function () {
  189. const $element = (parent, tag, style, content, css) => {
  190. let el = document.createElement(tag);
  191. if (style) el.style.cssText = style;
  192. if (typeof content !== 'undefined') {
  193. if (tag == 'input') {
  194. if (content == 'checkbox') el.type = content;
  195. else el.value = content;
  196. } else el.innerHTML = content;
  197. }
  198. if (css) css.split(' ').forEach(c => el.classList.add(c));
  199. parent.appendChild(el);
  200. return el;
  201. };
  202. let wapper = $element(document.body, 'div', 'position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; background-color: #0009; z-index: 10;');
  203. let wapper_close;
  204. wapper.onmousedown = e => {
  205. wapper_close = e.target == wapper;
  206. };
  207. wapper.onmouseup = e => {
  208. if (wapper_close && e.target == wapper) wapper.remove();
  209. };
  210. let dialog = $element(wapper, 'div', 'position: absolute; left: 50%; top: 50%; transform: translateX(-50%) translateY(-50%); width: fit-content; width: -moz-fit-content; background-color: #f3f3f3; border: 1px solid #ccc; border-radius: 10px; color: black;');
  211. let title = $element(dialog, 'h3', 'margin: 10px 20px;', lang.dialog.title);
  212. let options = $element(dialog, 'div', 'margin: 10px; border: 1px solid #ccc; border-radius: 5px;');
  213. let save_history_label = $element(options, 'label', 'display: block; margin: 10px;', lang.dialog.save_history);
  214. let save_history_input = $element(save_history_label, 'input', 'float: left;', 'checkbox');
  215. save_history_input.checked = await GM_getValue('save_history', true);
  216. save_history_input.onchange = () => {
  217. GM_setValue('save_history', save_history_input.checked);
  218. }
  219. let clear_history = $element(save_history_label, 'label', 'display: inline-block; margin: 0 10px; color: blue;', lang.dialog.clear_history);
  220. clear_history.onclick = () => {
  221. if (confirm(lang.dialog.clear_confirm)) {
  222. history = [];
  223. GM_setValue('download_history', []);
  224. }
  225. };
  226. let show_sensitive_label = $element(options, 'label', 'display: block; margin: 10px;', lang.dialog.show_sensitive);
  227. let show_sensitive_input = $element(show_sensitive_label, 'input', 'float: left;', 'checkbox');
  228. show_sensitive_input.checked = await GM_getValue('show_sensitive', false);
  229. show_sensitive_input.onchange = () => {
  230. show_sensitive = show_sensitive_input.checked;
  231. GM_setValue('show_sensitive', show_sensitive);
  232. };
  233. let filename_div = $element(dialog, 'div', 'margin: 10px; border: 1px solid #ccc; border-radius: 5px;');
  234. let filename_label = $element(filename_div, 'label', 'display: block; margin: 10px 15px;', lang.dialog.pattern);
  235. let filename_input = $element(filename_label, 'textarea', 'display: block; min-width: 500px; max-width: 500px; min-height: 100px; font-size: inherit; background: white; color: black;', await GM_getValue('filename', filename));
  236. let filename_tags = $element(filename_div, 'label', 'display: table; margin: 10px;', `
  237. <span class="tmd-tag" title="user name">{user-name}</span>
  238. <span class="tmd-tag" title="The user name after @ sign.">{user-id}</span>
  239. <span class="tmd-tag" title="example: 1234567890987654321">{status-id}</span>
  240. <span class="tmd-tag" title="{date-time} : Posted time in UTC.\n{date-time-local} : Your local time zone.\n\nDefault:\nYYYYMMDD-hhmmss => 20201231-235959\n\nExample of custom:\n{date-time:DD-MMM-YY hh.mm} => 31-DEC-21 23.59">{date-time}</span><br>
  241. <span class="tmd-tag" title="Text content in tweet.">{full-text}</span>
  242. <span class="tmd-tag" title="Type of &#34;video&#34; or &#34;photo&#34; or &#34;gif&#34;.">{file-type}</span>
  243. <span class="tmd-tag" title="Original filename from URL.">{file-name}</span>
  244. `);
  245. filename_input.selectionStart = filename_input.value.length;
  246. filename_tags.querySelectorAll('.tmd-tag').forEach(tag => {
  247. tag.onclick = () => {
  248. let ss = filename_input.selectionStart;
  249. let se = filename_input.selectionEnd;
  250. filename_input.value = filename_input.value.substring(0, ss) + tag.innerText + filename_input.value.substring(se);
  251. filename_input.selectionStart = ss + tag.innerText.length;
  252. filename_input.selectionEnd = ss + tag.innerText.length;
  253. filename_input.focus();
  254. };
  255. });
  256. let btn_save = $element(title, 'label', 'float: right;', lang.dialog.save, 'tmd-btn');
  257. btn_save.onclick = async () => {
  258. await GM_setValue('filename', filename_input.value);
  259. wapper.remove();
  260. };
  261. },
  262. fetchJson: async function (status_id) {
  263. let base_url = `https://${host}/i/api/graphql/NmCeCgkVlsRGS1cAwqtgmw/TweetDetail`;
  264. let variables = {
  265. "focalTweetId":status_id,
  266. "with_rux_injections":false,
  267. "includePromotedContent":true,
  268. "withCommunity":true,
  269. "withQuickPromoteEligibilityTweetFields":true,
  270. "withBirdwatchNotes":true,
  271. "withVoice":true,
  272. "withV2Timeline":true
  273. };
  274. let features = {
  275. "rweb_lists_timeline_redesign_enabled":true,
  276. "responsive_web_graphql_exclude_directive_enabled":true,
  277. "verified_phone_label_enabled":false,
  278. "creator_subscriptions_tweet_preview_api_enabled":true,
  279. "responsive_web_graphql_timeline_navigation_enabled":true,
  280. "responsive_web_graphql_skip_user_profile_image_extensions_enabled":false,
  281. "tweetypie_unmention_optimization_enabled":true,
  282. "responsive_web_edit_tweet_api_enabled":true,
  283. "graphql_is_translatable_rweb_tweet_is_translatable_enabled":true,
  284. "view_counts_everywhere_api_enabled":true,
  285. "longform_notetweets_consumption_enabled":true,
  286. "responsive_web_twitter_article_tweet_consumption_enabled":false,
  287. "tweet_awards_web_tipping_enabled":false,
  288. "freedom_of_speech_not_reach_fetch_enabled":true,
  289. "standardized_nudges_misinfo":true,
  290. "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled":true,
  291. "longform_notetweets_rich_text_read_enabled":true,
  292. "longform_notetweets_inline_media_enabled":true,
  293. "responsive_web_media_download_video_enabled":false,
  294. "responsive_web_enhance_cards_enabled":false
  295. };
  296. let url = encodeURI(`${base_url}?variables=${JSON.stringify(variables)}&features=${JSON.stringify(features)}`);
  297. let cookies = this.getCookie();
  298. let headers = {
  299. 'authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
  300. 'x-twitter-active-user': 'yes',
  301. 'x-twitter-client-language': cookies.lang,
  302. 'x-csrf-token': cookies.ct0
  303. };
  304. if (cookies.ct0.length == 32) headers['x-guest-token'] = cookies.gt;
  305. let tweet_detail = await fetch(url, {headers: headers}).then(result => result.json());
  306. let tweet_entrie = tweet_detail.data.threaded_conversation_with_injections_v2.instructions[0].entries.find(n => n.entryId == `tweet-${status_id}`);
  307. let tweet_result = tweet_entrie.content.itemContent.tweet_results.result;
  308. return tweet_result.tweet || tweet_result;
  309. },
  310. getCookie: function (name) {
  311. let cookies = {};
  312. document.cookie.split(';').filter(n => n.indexOf('=') > 0).forEach(n => {
  313. n.replace(/^([^=]+)=(.+)$/, (match, name, value) => {
  314. cookies[name.trim()] = value.trim();
  315. });
  316. });
  317. return name ? cookies[name] : cookies;
  318. },
  319. storage: async function (value) {
  320. let data = await GM_getValue('download_history', []);
  321. let data_length = data.length;
  322. if (value) {
  323. if (Array.isArray(value)) data = data.concat(value);
  324. else if (data.indexOf(value) < 0) data.push(value);
  325. } else return data;
  326. if (data.length > data_length) GM_setValue('download_history', data);
  327. },
  328. storage_obsolete: function (is_remove) {
  329. let data = JSON.parse(localStorage.getItem('history') || '[]');
  330. if (is_remove) localStorage.removeItem('history');
  331. else return data;
  332. },
  333. formatDate: function (i, o, tz) {
  334. let d = new Date(i);
  335. if (tz) d.setMinutes(d.getMinutes() - d.getTimezoneOffset());
  336. let m = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'];
  337. let v = {
  338. YYYY: d.getUTCFullYear().toString(),
  339. YY: d.getUTCFullYear().toString(),
  340. MM: d.getUTCMonth() + 1,
  341. MMM: m[d.getUTCMonth()],
  342. DD: d.getUTCDate(),
  343. hh: d.getUTCHours(),
  344. mm: d.getUTCMinutes(),
  345. ss: d.getUTCSeconds(),
  346. h2: d.getUTCHours() % 12,
  347. ap: d.getUTCHours() < 12 ? 'AM' : 'PM'
  348. };
  349. return o.replace(/(YY(YY)?|MMM?|DD|hh|mm|ss|h2|ap)/g, n => ('0' + v[n]).substr(-n.length));
  350. },
  351. downloader: (function () {
  352. let tasks = [], thread = 0, max_thread = 2, retry = 0, max_retry = 2, failed = 0, notifier, has_failed = false;
  353. return {
  354. add: function (task) {
  355. tasks.push(task);
  356. if (thread < max_thread) {
  357. thread += 1;
  358. this.next();
  359. } else this.update();
  360. },
  361. next: async function () {
  362. let task = tasks.shift();
  363. await this.start(task);
  364. if (tasks.length > 0 && thread <= max_thread) this.next();
  365. else thread -= 1;
  366. this.update();
  367. },
  368. start: function (task) {
  369. this.update();
  370. return new Promise(resolve => {
  371. const imageData = {
  372. url: task.url,
  373. name: task.name,
  374. folders: [], // 可選項,指定儲存的資料夾
  375. tags: [], // 可選項,指定標籤
  376. website: task.url, // 可選項,指定來源網站名稱
  377. headers: {} // 可選項,指定額外的 HTTP 標頭
  378. };
  379.  
  380. GM_xmlhttpRequest({
  381. url: "http://localhost:41595/api/item/addFromURL",
  382. method: "POST",
  383. headers: {
  384. "Content-Type": "application/json"
  385. },
  386. data: JSON.stringify(imageData),
  387. onload: response => {
  388. if (response.status >= 200 && response.status < 300) {
  389. task.onload();
  390. console.log('Image added to Eagle:', response);
  391. } else {
  392. console.error('Failed to add image to Eagle:', response);
  393. this.retry(task, response);
  394. }
  395. resolve();
  396. },
  397. onerror: error => {
  398. console.error('Failed to add image to Eagle:', error);
  399. this.retry(task, error);
  400. resolve();
  401. },
  402. ontimeout: error => {
  403. console.error('Timeout adding image to Eagle:', error);
  404. this.retry(task, error);
  405. resolve();
  406. }
  407. });
  408. });
  409. },
  410. retry: function (task, result) {
  411. retry += 1;
  412. if (retry == 3) max_thread = 1;
  413. if (task.retry && task.retry >= max_retry ||
  414. result.details && result.details.current == 'USER_CANCELED') {
  415. task.onerror(result);
  416. failed += 1;
  417. } else {
  418. if (max_thread == 1) task.retry = (task.retry || 0) + 1;
  419. this.add(task);
  420. }
  421. },
  422. update: function() {
  423. if (!notifier) {
  424. notifier = document.createElement('div');
  425. notifier.title = 'Twitter Media Downloader';
  426. notifier.classList.add('tmd-notifier');
  427. notifier.innerHTML = '<label>0</label>|<label>0</label>';
  428. document.body.appendChild(notifier);
  429. }
  430. if (failed > 0 && !has_failed) {
  431. has_failed = true;
  432. notifier.innerHTML += '|';
  433. let clear = document.createElement('label');
  434. notifier.appendChild(clear);
  435. clear.onclick = () => {
  436. notifier.innerHTML = '<label>0</label>|<label>0</label>';
  437. failed = 0;
  438. has_failed = false;
  439. this.update();
  440. };
  441. }
  442. notifier.firstChild.innerText = thread;
  443. notifier.firstChild.nextElementSibling.innerText = tasks.length;
  444. if (failed > 0) notifier.lastChild.innerText = failed;
  445. if (thread > 0 || tasks.length > 0 || failed > 0) notifier.classList.add('running');
  446. else notifier.classList.remove('running');
  447. }
  448. };
  449. })(),
  450. language: {
  451. en: {download: 'Download', completed: 'Download Completed', settings: 'Settings', dialog: {title: 'Download Settings', save: 'Save', save_history: 'Remember download history', clear_history: '(Clear)', clear_confirm: 'Clear download history?', show_sensitive: 'Always show sensitive content', pattern: 'File Name Pattern'}},
  452. ko: {download: '다운로드', completed: '다운로드 완려', settings: '세팅', dialog: {title: '다운로드 세팅', save: '저장', save_history: '다운로드 기록 저장', clear_history: '(비우기)', clear_confirm: '다운로드 히스토리를 비울까요?', show_sensitive: '민감한 이미지 표시', pattern: '파일 이름 패턴'}},
  453. ja: {download: 'ダウンロード', completed: 'ダウンロード完了', settings: '設定', dialog: {title: 'ダウンロード設定', save: '保存', save_history: 'ダウンロード履歴を保存する', clear_history: '(クリア)', clear_confirm: 'ダウンロード履歴を削除する?', show_sensitive: 'センシティブな内容を常に表示する', pattern: 'ファイル名パターン'}},
  454. zh: {download: '下载', completed: '下载完成', settings: '设置', dialog: {title: '下载设置', save: '保存', save_history: '保存下载记录', clear_history: '(清除)', clear_confirm: '确认要清除下载记录?', show_sensitive: '自动显示敏感的内容', pattern: '文件名格式'}},
  455. 'zh-Hant': {download: '下載', completed: '下載完成', settings: '設置', dialog: {title: '下載設置', save: '保存', save_history: '保存下載記錄', clear_history: '(清除)', clear_confirm: '確認要清除下載記錄?', show_sensitive: '自動顯示敏感的内容', pattern: '文件名規則'}}
  456. },
  457. css: `
  458. .tmd-down {margin-left: 12px; order: 99;}
  459. .tmd-down:hover > div > div > div > div {color: rgba(29, 161, 242, 1.0);}
  460. .tmd-down:hover > div > div > div > div > div {background-color: rgba(29, 161, 242, 0.1);}
  461. .tmd-down:active > div > div > div > div > div {background-color: rgba(29, 161, 242, 0.2);}
  462. .tmd-down:hover svg {color: rgba(29, 161, 242, 1.0);}
  463. .tmd-down:hover div:first-child:not(:last-child) {background-color: rgba(29, 161, 242, 0.1);}
  464. .tmd-down:active div:first-child:not(:last-child) {background-color: rgba(29, 161, 242, 0.2);}
  465. .tmd-down.tmd-media {position: absolute; right: 0;}
  466. .tmd-down.tmd-media > div {display: flex; border-radius: 99px; margin: 2px;}
  467. .tmd-down.tmd-media > div > div {display: flex; margin: 6px; color: #fff;}
  468. .tmd-down.tmd-media:hover > div {background-color: rgba(255,255,255, 0.6);}
  469. .tmd-down.tmd-media:hover > div > div {color: rgba(29, 161, 242, 1.0);}
  470. .tmd-down.tmd-media:not(:hover) > div > div {filter: drop-shadow(0 0 1px #000);}
  471. .tmd-down g {display: none;}
  472. .tmd-down.download g.download, .tmd-down.completed g.completed, .tmd-down.loading g.loading,.tmd-down.failed g.failed {display: unset;}
  473. .tmd-down.loading svg {animation: spin 1s linear infinite;}
  474. @keyframes spin {0% {transform: rotate(0deg);} 100% {transform: rotate(360deg);}}
  475. .tmd-btn {display: inline-block; background-color: #1DA1F2; color: #FFFFFF; padding: 0 20px; border-radius: 99px;}
  476. .tmd-tag {display: inline-block; background-color: #FFFFFF; color: #1DA1F2; padding: 0 10px; border-radius: 10px; border: 1px solid #1DA1F2; font-weight: bold; margin: 5px;}
  477. .tmd-btn:hover {background-color: rgba(29, 161, 242, 0.9);}
  478. .tmd-tag:hover {background-color: rgba(29, 161, 242, 0.1);}
  479. .tmd-notifier {display: none; position: fixed; left: 16px; bottom: 16px; color: #000; background: #fff; border: 1px solid #ccc; border-radius: 8px; padding: 4px;}
  480. .tmd-notifier.running {display: flex; align-items: center;}
  481. .tmd-notifier label {display: inline-flex; align-items: center; margin: 0 8px;}
  482. .tmd-notifier label:before {content: " "; width: 32px; height: 16px; background-position: center; background-repeat: no-repeat;}
  483. .tmd-notifier label:nth-child(1):before {background-image:url("data:image/svg+xml;charset=utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 24 24%22><path d=%22M3,14 v5 q0,2 2,2 h14 q2,0 2,-2 v-5 M7,10 l4,4 q1,1 2,0 l4,-4 M12,3 v11%22 fill=%22none%22 stroke=%22%23666%22 stroke-width=%222%22 stroke-linecap=%22round%22 /></svg>");}
  484. .tmd-notifier label:nth-child(2):before {background-image:url("data:image/svg+xml;charset=utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 24 24%22><path d=%22M12,2 a1,1 0 0 1 0,20 a1,1 0 0 1 0,-20 M12,5 v7 h6%22 fill=%22none%22 stroke=%22%23999%22 stroke-width=%222%22 stroke-linejoin=%22round%22 stroke-linecap=%22round%22 /></svg>");}
  485. .tmd-notifier label:nth-child(3):before {background-image:url("data:image/svg+xml;charset=utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 24 24%22><path d=%22M12,0 a2,2 0 0 0 0,24 a2,2 0 0 0 0,-24%22 fill=%22%23f66%22 stroke=%22none%22 /><path d=%22M14.5,5 a1,1 0 0 0 -5,0 l0.5,9 a1,1 0 0 0 4,0 z M12,17 a2,2 0 0 0 0,5 a2,2 0 0 0 0,-5%22 fill=%22%23fff%22 stroke=%22none%22 /></svg>");}
  486. .tmd-down.tmd-img {position: absolute; right: 0; bottom: 0; display: none !important;}
  487. .tmd-down.tmd-img > div {display: flex; border-radius: 99px; margin: 2px; background-color: rgba(255,255,255, 0.6);}
  488. .tmd-down.tmd-img > div > div {display: flex; margin: 6px; color: #fff !important;}
  489. .tmd-down.tmd-img:not(:hover) > div > div {filter: drop-shadow(0 0 1px #000);}
  490. .tmd-down.tmd-img:hover > div > div {color: rgba(29, 161, 242, 1.0);}
  491. :hover > .tmd-down.tmd-img, .tmd-img.loading, .tmd-img.completed, .tmd-img.failed {display: block !important;}
  492. .tweet-detail-action-item {width: 20% !important;}
  493. `,
  494. css_ss: `
  495. /* show sensitive in media tab */
  496. li[role="listitem"]>div>div>div>div:not(:last-child) {filter: none;}
  497. li[role="listitem"]>div>div>div>div+div:last-child {display: none;}
  498. `,
  499. svg: `
  500. <g class="download"><path d="M3,14 v5 q0,2 2,2 h14 q2,0 2,-2 v-5 M7,10 l4,4 q1,1 2,0 l4,-4 M12,3 v11" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></g>
  501. <g class="completed"><path d="M3,14 v5 q0,2 2,2 h14 q2,0 2,-2 v-5 M7,10 l3,4 q1,1 2,0 l8,-11" fill="none" stroke="#1DA1F2" stroke-width="2" stroke-linecap="round" /></g>
  502. <g class="loading"><circle cx="12" cy="12" r="10" fill="none" stroke="#1DA1F2" stroke-width="4" opacity="0.4" /><path d="M12,2 a10,10 0 0 1 10,10" fill="none" stroke="#1DA1F2" stroke-width="4" stroke-linecap="round" /></g>
  503. <g class="failed"><circle cx="12" cy="12" r="11" fill="#f33" stroke="currentColor" stroke-width="2" opacity="0.8" /><path d="M14,5 a1,1 0 0 0 -4,0 l0.5,9.5 a1.5,1.5 0 0 0 3,0 z M12,17 a2,2 0 0 0 0,4 a2,2 0 0 0 0,-4" fill="#fff" stroke="none" /></g>
  504. `
  505. };
  506. })();
  507.  
  508. TMD.init();

QingJ © 2025

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