🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/06 06:41:44
🔄 下次更新时间:2026/01/06 07:41:44
手动刷新缓存

Twitter Video Download

Adds a button to download video from a tweet

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         Twitter Video Download
// @namespace    http://tampermonkey.net/
// @version      1.0.10
// @description  Adds a button to download video from a tweet
// @run-at       document-idle
// @author       naileD
// @match        https://x.com/*
// @match        https://mobile.x.com/*
// @match        https://twitter.com/*
// @match        https://mobile.twitter.com/*
// @icon         https://www.google.com/s2/favicons?domain=x.com
// @grant        unsafeWindow
// @license      Unlicense
// ==/UserScript==

'use strict';
setInterval(() => {
  var doc = unsafeWindow.document;
  if (unsafeWindow.wrappedJSObject) doc = unsafeWindow.wrappedJSObject.document; //Violentmonkey fix
  var main = doc.querySelector("main[role='main'] section[role='region']");
  if (!main) return;
  var react = Object.entries(main.parentElement).find(el => el[0].startsWith("__reactFiber"));
  if (!react || !react[1] || !react[1].memoizedProps.children.length) return;
  var tweet = [...react[1].memoizedProps.children].filter(el => (el || {})._owner).map(el => el._owner.memoizedProps.focalTweet).filter(el => el)[0];
  if (!tweet || !tweet.extended_entities || !tweet.extended_entities.media || ![...tweet.extended_entities.media].find(el => el.video_info)) return;
  var el = doc.querySelector(`a[href*="${tweet.id_str}"]`);
  if (!el) return;
  while (el.tagName !== "ARTICLE") { el = el.parentElement; }
  el = el.querySelector(`[id^="id"][role="group"]`);
  if (!el) return;
  if (el.lastElementChild.tagName === "A") return;
  var videoInfos = [...tweet.extended_entities.media].filter(el => el.video_info);
  var videos = videoInfos.map(el => [...el.video_info.variants].filter(v => v.content_type == "video/mp4").sort((a,b) => b.bitrate - a.bitrate)[0].url.replace(new RegExp("\\?tag=.*"), ""));
  var color = el.firstElementChild.style.color || "#536471";
  var svg = `<svg width="1.5em" height="1.5em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs">
          <g><path d="M18 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8c0-1.1.9-2 2-2h5M15 3h6v6M10 14L20.2 3.8"/></g></svg>`;
  videos.forEach(video => el.insertAdjacentHTML("beforeend", `<a href="${video}" target="_blank" style="display: flex; place-self: center;  color: ${color};" title="Download Video">${svg}</a>`));
}, 1000);