批量添加视频到合集

搜索后,按快捷键 alt+z 开始添加,s 停止

  1. // ==UserScript==
  2. // @name 批量添加视频到合集
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-03-31
  5. // @description 搜索后,按快捷键 alt+z 开始添加,s 停止
  6. // @author You
  7. // @match https://member.bilibili.com/platform/upload-manager/ep
  8. // @icon https://www.bilibili.com/favicon.ico
  9. // @grant GM_addStyle
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. GM_addStyle(`
  14. .title-text-content {
  15. overflow: visible !important;
  16. }
  17.  
  18. .title-icon {
  19. visibility: hidden !important;
  20. }
  21. `);
  22.  
  23. (function() {
  24. 'use strict';
  25. // Your code here...
  26.  
  27. let isRunning = false; // 标志位,控制是否继续运行
  28.  
  29. document.addEventListener('keydown', function (event) {
  30. // 按下 "alt+z" 键启动逻辑
  31. if (event.altKey && event.key === 'z') {
  32. if (isRunning) {
  33. console.log('操作已在运行中');
  34. return; // 防止重复启动
  35. }
  36.  
  37. isRunning = true; // 设置为运行状态
  38. const container = document.querySelector('.ep-select-box-item'); // 滚动容器
  39. const height = document.querySelector('.ep-select-box-item-all')?.offsetHeight || 0; // 单个元素高度
  40. if (!container || height === 0) {
  41. console.error('未找到滚动容器或元素高度为 0');
  42. isRunning = false; // 结束运行
  43. return;
  44. }
  45.  
  46. let deleteFinished = false;
  47. let checkCount = 0;
  48.  
  49. // 定义一个函数来处理滚动和操作
  50. function processNext() {
  51. if (!isRunning) {
  52. console.log('操作已停止');
  53. return; // 如果标志位为 false,停止递归
  54. }
  55.  
  56. if (!deleteFinished) {
  57. // 删除已禁用的元素
  58. const disabledElement = document.querySelector('.ep-select-box-item-all-disabled');
  59. if (disabledElement) {
  60. disabledElement.remove(); // 删除元素
  61. } else {
  62. console.log('所有禁用元素已删除');
  63. deleteFinished = true;
  64. }
  65. } else {
  66. // 查找未勾选的复选框
  67. const checkbox = document.querySelector('.icon-checkbox');
  68. if (checkbox && checkCount < 50) {
  69. checkbox.click(); // 点击勾选
  70. checkCount++;
  71. } else {
  72. isRunning = false; // 停止运行
  73. console.log('勾选至上限,操作已停止');
  74. return;
  75. }
  76. }
  77.  
  78. // 滚动到下一个元素
  79. container.scrollBy({ top: height, behavior: 'smooth' });
  80.  
  81. // 递归调用,处理下一个元素
  82. setTimeout(processNext, 300); // 延迟 300ms,等待滚动完成
  83. }
  84.  
  85. // 开始处理
  86. processNext();
  87. }
  88.  
  89. // 按下 "S" 键停止逻辑
  90. if (event.key === 's') {
  91. isRunning = false; // 设置标志位为 false,停止运行
  92. console.log('操作已停止');
  93. }
  94. });
  95.  
  96.  
  97. })();

QingJ © 2025

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