抖音用户主页视频链接提取器

提取抖音用户主页中的视频链接,并添加复制所有链接的悬浮按钮

  1. // ==UserScript==
  2. // @name 抖音用户主页视频链接提取器
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 提取抖音用户主页中的视频链接,并添加复制所有链接的悬浮按钮
  6. // @author 骄阳哥
  7. // @match https://www.douyin.com/user/MS4*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=douyin.com
  9. // @grant GM_setClipboard
  10. // @run-at document-end
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. let videoLinks = []; // 存储提取到的视频链接
  18.  
  19. function extractVideoLinks() {
  20. // 获取包含视频列表的元素
  21. const videoList = document.querySelector('div[data-e2e="user-post-list"]');
  22. if (!videoList) {
  23. console.log('未找到视频列表元素');
  24. return;
  25. }
  26.  
  27. // 提取所有以 "/video/" 开头的链接
  28. videoLinks = [...videoList.querySelectorAll('a[href^="/video/"]')].map(a => a.href);
  29.  
  30. // 在控制台输出视频链接
  31. console.log('提取到的视频链接:');
  32. videoLinks.forEach(link => console.log(link));
  33. }
  34.  
  35. function createFloatButton() {
  36. const button = document.createElement('button');
  37. button.textContent = '复制所有视频链接';
  38. button.style.position = 'fixed';
  39. button.style.right = '20px';
  40. button.style.top = '50%';
  41. button.style.transform = 'translateY(-50%)';
  42. button.style.zIndex = '9999';
  43. button.style.padding = '10px';
  44. button.style.backgroundColor = '#ff0050';
  45. button.style.color = 'white';
  46. button.style.border = 'none';
  47. button.style.borderRadius = '4px';
  48. button.style.cursor = 'pointer';
  49. button.addEventListener('click', copyVideoLinks);
  50. document.body.appendChild(button);
  51. }
  52.  
  53. function copyVideoLinks() {
  54. extractVideoLinks()
  55. if (videoLinks.length === 0) {
  56. alert('未提取到视频链接,请等待页面加载完成后重试。');
  57. return;
  58. }
  59. GM_setClipboard(videoLinks.join('\n'));
  60. alert(`已复制 ${videoLinks.length} 个视频链接到剪贴板。`);
  61. }
  62.  
  63. // 在页面加载完成后提取视频链接
  64. //window.addEventListener('load', extractVideoLinks);
  65.  
  66. // 创建悬浮按钮
  67. createFloatButton();
  68. })();

QingJ © 2025

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