// ==UserScript== // @name TikTok Video Downloader // @namespace https://www.laconicdesigns.com // @version 0.1 // @description Adds a download button to tiktok.com/@profile/video pages. Click a video, the icon is added by the social media share buttons. Right click the icon, and save as. Left click takes you to the video in your browser. // @author Blake B // @match https://www.tiktok.com/@* // @grant none // @downloadURL https://update.greasyfork.icu/scripts/391936/TikTok%20Video%20Downloader.user.js // @updateURL https://update.greasyfork.icu/scripts/391936/TikTok%20Video%20Downloader.meta.js // ==/UserScript== (function() { 'use strict'; function showDownloadButton(url_to_download) { if (document.body.contains(document.getElementById("blake_dl_btn")) == true) { document.getElementByid("blake_dl_btn").remove(); //It pulls 2 links at a time because of the one on the main page. } var elem_button = document.createElement("A"); //Anchor tag elem_button.setAttribute("href", url_to_download); //Download URL elem_button.setAttribute("id", "blake_dl_btn"); //So we can find it later //This is the icon. It's the easiest way to do this, and keep it shareable. elem_button.innerHTML = ""; //This needs to be set to an svg download icon var share_buttons = document.getElementsByClassName("_share_content"); share_buttons[share_buttons.length - 1].appendChild(elem_button); } var element_to_observe = document.body; //I Watch Everything... var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes.length == 1) { var top_node = mutation.addedNodes[0]; // The added node var vid_node_total = top_node.getElementsByTagName("VIDEO").length; // Looking for