Twitter 网页版多视频/gif下载.[limbopro]

Twitter 网页版视频/gif下载(GIF/单/多视频解析及下载)

// ==UserScript==
// @name         Twitter 网页版多视频/gif下载.[limbopro]
// @namespace    https://limbopro.com/
// @version      0.1.3.9
// @description  Twitter 网页版视频/gif下载(GIF/单/多视频解析及下载)
// @author       limbopro
// @license MIT
// @match        https://twitter.com/*
// @match        https://x.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        none
// ==/UserScript==



(function () {
    'use strict';
    setInterval(() => {
        if (document.querySelectorAll('[data-testid="cellInnerDiv"]')) {
            var article = document.querySelectorAll('[data-testid="cellInnerDiv"]')

            
            for (let i = 0; i < article.length; i++) {
                if (!article[i].querySelector('a[href*=greasyfork]')) {
                    if (article[i].querySelector('[data-testid="videoPlayer"]')) {
                        console.log(article[i].textContent);
                        let a = document.createElement('a')
                        a.href = 'https://greasyfork.org/zh-CN/scripts/478651-twitter-%E7%BD%91%E9%A1%B5%E7%89%88%E5%A4%9A%E8%A7%86%E9%A2%91%E4%B8%8B%E8%BD%BD-limbopro';
                        a.className = 'greasyfork'
                        a.target = '_blank';
                        a.zIndex = '114154';
                        a.style = 'text-decoration:none; cursor:help; position:absolute; right:295px;top:5px;background:linear-gradient(rgb(62 53 53) 0%, rgb(31 29 29) 100%);text-transform:uppercase;padding:6px 12px;box-shadow:rgb(0 0 0) 0px 2px 2px inset;color:white;z-index:114154;padding-right:15px;'
                        a.textContent = "如何下载视频/Gif?";
                        if (article[i].querySelectorAll("div[class='css-175oi2r r-1p0dtai r-1d2f490 r-u8s1d r-zchlnj r-ipm5af r-1loqt21']")[0]) {
                            article[i].querySelectorAll("div[class='css-175oi2r r-1p0dtai r-1d2f490 r-u8s1d r-zchlnj r-ipm5af r-1loqt21']")[0].appendChild(a);
                        } else {
                            article[i].appendChild(a);
                        }
                    }
                }
            }

    

            for (let i = 0; i < article.length; i++) {
                if (!article[i].querySelector('a[href*=twittervid]')) {
                    if (article[i].querySelector('[data-testid="videoPlayer"]')) {
                        console.log(article[i].textContent);
                        let a = document.createElement('a')
                        a.href = 'https://twittervid.com/';
                        a.className = 'twittervid'
                        a.target = '_blank';
                        a.zIndex = '114154';
                        a.style = 'text-decoration:none; position:absolute;right:173px;top:5px;background:linear-gradient(to bottom, #66BB6A 0%, #43A047 100%);text-transform:uppercase;padding:6px 12px;box-shadow:inset 0 2px 2px #388E3C;color:white;z-index:114154;padding-right:15px;'
                        a.textContent = "通过[vid]下载";
                        if (article[i].querySelectorAll("div[class='css-175oi2r r-1p0dtai r-1d2f490 r-u8s1d r-zchlnj r-ipm5af r-1loqt21']")[0]) {
                            article[i].querySelectorAll("div[class='css-175oi2r r-1p0dtai r-1d2f490 r-u8s1d r-zchlnj r-ipm5af r-1loqt21']")[0].appendChild(a);
                        } else {
                            article[i].appendChild(a);
                        }
                    }
                }
            }



            for (let i = 0; i < article.length; i++) {
                if (!article[i].querySelector('a[href*=twittervideodownloader]')) {
                    if (article[i].querySelector('[data-testid="videoPlayer"]')) {
                        console.log(article[i].textContent);
                        let a = document.createElement('a')
                        a.href = 'https://twittervideodownloader.com/';
                        a.className = 'twittervideodownloader'
                        a.target = '_blank';
                        a.zIndex = '114155';
                        a.style = 'text-decoration:none; position:absolute;right:15px;top:5px;background:linear-gradient(to bottom, #42a5f5 0%, #1e88e5 100%);text-transform:uppercase;padding:6px 12px;box-shadow:inset 0 2px 2px #1976d2;color:white;z-index:114154;padding-right:15px;'
                        a.textContent = "通过[loader]下载";
                        if (article[i].querySelectorAll("div[class='css-175oi2r r-1p0dtai r-1d2f490 r-u8s1d r-zchlnj r-ipm5af r-1loqt21']")[0]) {
                            article[i].querySelectorAll("div[class='css-175oi2r r-1p0dtai r-1d2f490 r-u8s1d r-zchlnj r-ipm5af r-1loqt21']")[0].appendChild(a);
                        } else {
                            article[i].appendChild(a);
                        }
                    }
                }
            }

        }
    }, 1000)
})();