Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 110Percent/7c54ec36b987397cd0b33581009cfb4c to your computer and use it in GitHub Desktop.
Save 110Percent/7c54ec36b987397cd0b33581009cfb4c to your computer and use it in GitHub Desktop.
Userscript to download tiktok videos shown in the browser, for ultimate memeing purposes. :)
// ==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,2000);
})();
function getVideoElements(){
return document.querySelectorAll('.video-player');
}
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.querySelector(".share-layout-content");
mainBody.appendChild(link);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment