Ethos TikTok Downloader

Adds a download button on TikTok.com and gives the user the option to Download the video or download the audio or just close the GUI. Uses the Ethos TikTok API.

目前为 2024-03-17 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Ethos TikTok Downloader
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Adds a download button on TikTok.com and gives the user the option to Download the video or download the audio or just close the GUI. Uses the Ethos TikTok API.
  6. // @author Shehajeez
  7. // @match *://*/*
  8. // @grant GM_xmlhttpRequest
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function istiktokurl(url) {
  15. return url.startsWith("https://vm.tiktok.com") ||
  16. url.startsWith("https://vt.tiktok.com") ||
  17. url.match(/^https:\/\/(www\.)?tiktok\.com\/@.+\/video\/\d+$/);
  18. }
  19.  
  20. function addguı() {
  21. const c = document.createElement('div');
  22. c.id = 'ttd-gui';
  23. c.style.position = 'fixed';
  24. c.style.top = '20px';
  25. c.style.right = '20px';
  26. c.style.background = '#333';
  27. c.style.padding = '10px';
  28. c.style.borderRadius = '10px';
  29. c.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08)';
  30. c.style.zIndex = '9999';
  31. c.style.transition = 'opacity 0.3s, transform 0.3s';
  32. c.style.opacity = '0';
  33. c.style.transform = 'scale(0.8)';
  34. c.style.fontFamily = 'Montserrat, sans-serif';
  35. c.style.color = '#fff';
  36. c.style.userSelect = 'none';
  37.  
  38. const b = document.createElement('button');
  39. b.innerText = 'X';
  40. b.style.position = 'absolute';
  41. b.style.top = '5px';
  42. b.style.right = '5px';
  43. b.style.border = 'none';
  44. b.style.background = 'none';
  45. b.style.color = '#fff';
  46. b.style.fontSize = '16px';
  47. b.style.cursor = 'pointer';
  48. b.style.fontFamily = 'Montserrat, sans-serif';
  49. b.style.transition = 'color 0.3s';
  50. b.addEventListener('mouseover', function() {
  51. b.style.color = '#f44336';
  52. });
  53. b.addEventListener('mouseleave', function() {
  54. b.style.color = '#fff';
  55. });
  56.  
  57. const v = cb('Download Video', '#4CAF50');
  58. const a = cb('Download Audio', '#2196F3');
  59.  
  60. c.appendChild(b);
  61. c.appendChild(v);
  62. c.appendChild(a);
  63.  
  64. document.body.appendChild(c);
  65.  
  66. v.addEventListener('click', function() {
  67. sdr('video');
  68. });
  69.  
  70. a.addEventListener('click', function() {
  71. sdr('audio');
  72. });
  73.  
  74. b.addEventListener('click', function() {
  75. c.style.opacity = '0';
  76. c.style.transform = 'scale(0.8)';
  77. setTimeout(() => {
  78. c.remove();
  79. }, 300);
  80. });
  81.  
  82. setTimeout(() => {
  83. c.style.opacity = '1';
  84. c.style.transform = 'scale(1)';
  85. }, 100);
  86. }
  87.  
  88. function cb(t, c) {
  89. const b = document.createElement('button');
  90. b.innerText = t;
  91. b.style.width = '100%';
  92. b.style.padding = '10px';
  93. b.style.marginTop = '10px';
  94. b.style.border = 'none';
  95. b.style.borderRadius = '5px';
  96. b.style.background = c;
  97. b.style.color = '#fff';
  98. b.style.fontSize = '16px';
  99. b.style.fontWeight = 'bold';
  100. b.style.cursor = 'pointer';
  101. b.style.transition = 'background 0.3s';
  102. b.style.fontFamily = 'Montserrat, sans-serif';
  103. b.addEventListener('mouseover', function() {
  104. b.style.background = d(c);
  105. });
  106. b.addEventListener('mouseleave', function() {
  107. b.style.background = c;
  108. });
  109. return b;
  110. }
  111.  
  112. function d(c) {
  113. const h = c.replace('#', '');
  114. const r = parseInt(h.substring(0, 2), 16);
  115. const g = parseInt(h.substring(2, 4), 16);
  116. const b = parseInt(h.substring(4, 6), 16);
  117. const dr = Math.round(r * 0.8);
  118. const dg = Math.round(g * 0.8);
  119. const db = Math.round(b * 0.8);
  120. return `#${(dr * 0x10000 + dg * 0x100 + db).toString(16).padStart(6, '0')}`;
  121. }
  122.  
  123. function sdr(t) {
  124. const u = window.location.href;
  125. const e = `https://ethos-testing.vercel.app/api/tiktok?link=${encodeURIComponent(u)}&type=${t}`;
  126.  
  127. GM_xmlhttpRequest({
  128. method: "GET",
  129. url: e,
  130. onload: function(response) {
  131. const r = JSON.parse(response.responseText);
  132. if (t === 'video' && r.video) {
  133. window.location.href = r.video;
  134. } else if (t === 'audio' && r.audio) {
  135. window.location.href = r.audio;
  136. } else {
  137. console.error("No download link available");
  138. }
  139. },
  140. onerror: function(error) {
  141. console.error("Error occurred while fetching download link", error);
  142. }
  143. });
  144. }
  145.  
  146. if (istiktokurl(window.location.href)) {
  147. addguı();
  148. }
  149. })();

QingJ © 2025

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