Tiktok Video Downloader🎬

Download tiktok videos without watermark

// ==UserScript==
// @name         Tiktok Video Downloader🎬
// @namespace    https://greasyfork.org/en/scripts/431826
// @version      1.2
// @description  Download tiktok videos without watermark
// @author       YAD
// @match        *://*.tiktok.com/*
// @icon         https://miro.medium.com/v2/resize:fit:512/1*KX6NTUUHWlCP4sCXz28TBA.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function addDownloadButton(video) {
        // Check if the video already has a download button
        if (video.nextElementSibling && video.nextElementSibling.classList.contains('download-btn')) {
            return;
        }

        // Create the download button
        const downloadBtn = document.createElement('button');
        downloadBtn.textContent = '⬇️';
        downloadBtn.className = 'download-btn';
        downloadBtn.style.position = 'absolute';
        downloadBtn.style.left = '10px';
        downloadBtn.style.bottom = '50%';
        downloadBtn.style.zIndex = '1000';
        downloadBtn.style.padding = '10px';
        downloadBtn.style.color = '#fff';
        downloadBtn.style.background = '#007bff';
        downloadBtn.style.border = 'none';
        downloadBtn.style.borderRadius = '50px';

        downloadBtn.addEventListener('click', function() {
            const url = video.src || video.querySelector('source').src;
            const a = document.createElement('a');
            a.href = url;
            a.download = url.split('/').pop();
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
        });

        video.parentNode.insertBefore(downloadBtn, video.nextSibling);
    }

    document.querySelectorAll('video').forEach(addDownloadButton);

    new MutationObserver(() => {
        document.querySelectorAll('video').forEach(addDownloadButton);
    }).observe(document.body, { childList: true, subtree: true });
})();