TikTok Video URL Extractor

Logs video links from a TikTok profile to your browsers console.

  1. // ==UserScript==
  2. // @name TikTok Video URL Extractor
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.tiktok.com/*
  5. // @grant none
  6. // @version 1.2
  7. // @license GPLv2
  8. // @author Flop7534
  9. // @description Logs video links from a TikTok profile to your browsers console.
  10. // ==/UserScript==
  11.  
  12. // IMPORTANT: You may need to edit the class which gets selected in var "x"
  13. // If needed, change it to the common class associated with each individual video element on the profile.
  14.  
  15. setTimeout(() => {
  16. var b = document.getElementsByClassName("tiktok-ba55d9-DivHeaderRightContainer");
  17. var myButton = document.createElement("button");
  18. myButton.innerHTML = "Save Links";
  19.  
  20. myButton.addEventListener("click", function () {
  21. var x = document.getElementsByClassName("tiktok-x6y88p-DivItemContainerV2");
  22. var i = 0;
  23. var y = x.length;
  24. var links = "";
  25.  
  26. while (i < y) {
  27. var link = x[i].children[0].children[0].children[0].children[0].attributes.href.value;
  28. links += link + "\n";
  29. i++;
  30. }
  31.  
  32. var url = new URL(window.location.href);
  33. var username = url.pathname.split("/")[1].replace("@", "");
  34. var currentDate = new Date().toISOString().split("T")[0];
  35. var fileName = username + "-" + currentDate + ".txt";
  36.  
  37. var blob = new Blob([links], { type: "text/plain" });
  38. var fileUrl = URL.createObjectURL(blob);
  39. var a = document.createElement("a");
  40. a.href = fileUrl;
  41. a.download = fileName;
  42. a.click();
  43. URL.revokeObjectURL(fileUrl);
  44. });
  45.  
  46. b[0].appendChild(myButton);
  47. }, 5000);