Forked from evan3334/download_tiktok_videos.user.js
Created
September 9, 2019 13:59
-
-
Save DevMensIT/24276661e052ab474ab9f0f71ef78688 to your computer and use it in GitHub Desktop.
Userscript to download tiktok videos shown in the browser, for ultimate memeing purposes. :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Download Tiktok Videos | |
// @namespace https://tiktok.com/ | |
// @version 0.1 | |
// @description Adds download links for videos, even on private accounts. | |
// @author Evan Straw | |
// @include http://*.tiktok.com/* | |
// @include https://*.tiktok.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
setTimeout(addDownloadLinks,100); | |
})(); | |
function getVideoElements(){ | |
return document.getElementsByTagName("video"); | |
} | |
function getNumVideos(){ | |
return getVideoElements().length; | |
} | |
function isPostPage(){ | |
return window.location.pathname.startsWith("/p/"); | |
} | |
function makeDLLink(url){ | |
let linkElement = document.createElement("A"); | |
linkElement.href = url; | |
linkElement.innerText = "Download Video"; | |
linkElement.target = "_blank"; | |
linkElement.style = "padding: 10px;font-size:2em;font-weight:bold;color:red;"; | |
return linkElement; | |
} | |
function addDownloadLinks(){ | |
if(getNumVideos() > 0){ | |
let videoElements = getVideoElements(); | |
let video = videoElements[0]; | |
let videoURL = video.src; | |
let link = makeDLLink(videoURL); | |
let mainBody = document.getElementById("mainBody"); | |
mainBody.appendChild(link); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment