Greasy Fork

Greasy Fork is available in English.

TikTok Watermarkless Video Downloader

Replace TikToks default "Download video" with non-watermarked download

目前为 2024-10-12 提交的版本。查看 最新版本

// ==UserScript==
// @name         TikTok Watermarkless Video Downloader
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Replace TikToks default "Download video" with non-watermarked download
// @author       LukysGaming
// @match        https://www.tiktok.com/*
// @grant        GM_download
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            const downloadButton = document.querySelector('li.css-1l1tdw6-LiItemWrapper.e5bhsb11');

            if (downloadButton) {
                const videoElement = document.querySelector('video');

                if (videoElement) {
                    const sourceURL = videoElement.querySelector('source')?.src;

                    if (sourceURL) {
                        downloadButton.onclick = function(event) {
                            event.stopImmediatePropagation();
                            event.preventDefault();

                            GM_download(sourceURL, 'video.mp4');
                        };

                        const spanElement = downloadButton.querySelector('span');
                        if (spanElement) {
                            spanElement.textContent = 'Download video';
                        }
                    }
                }
            }
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();