TikTok Downloader

Tiktok Video Downloader

  1. // ==UserScript==
  2. // @name TikTok Downloader
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Tiktok Video Downloader
  6. // @author You
  7. // @match https://www.tiktok.com/foryou*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=tiktok.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. var downloadFile = function(url, name){
  16. var ajax=new XMLHttpRequest();
  17. ajax.open( "GET", url, true);
  18. ajax.responseType = 'blob';
  19. ajax.onload= function(e){
  20. saveBlob(e.target.response, name, 'video/mp4');
  21. };
  22. setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return:
  23. return ajax;
  24. };
  25. var saveBlob = function(blob, fileName) {
  26. var a = document.createElement('a');
  27. a.href = window.URL.createObjectURL(blob);
  28. a.download = fileName;
  29. a.dispatchEvent(new MouseEvent('click'));
  30. }
  31. var toogle_btn = document.createElement("button");
  32. toogle_btn.innerHTML = '🔽';
  33. toogle_btn.setAttribute(
  34. "style",
  35. "position: fixed;height: 30px;width: 30px;top: 100px;left: 5px;/z-index: 9999;border: none;background: #fff0;font-size: 27px;padding: 0px 0px 0px 0;opacity: 0.4;"
  36. );
  37. var download_video = function () {
  38. var timeNow = new Date();
  39. var fileName = timeNow.toLocaleDateString().replaceAll('/', '-') + timeNow.toLocaleTimeString().replaceAll(':', "-");
  40. var videoTag = document.getElementsByTagName('video')[0];
  41. downloadFile(videoTag.src, fileName);
  42. }
  43. toogle_btn.addEventListener('click', download_video);
  44. document.body.appendChild(toogle_btn);
  45. // Your code here...
  46. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址