飞书妙记-下载字幕和txt

让你更加便捷地下载飞书妙记生成的字幕文件和txt文件.

  1. // ==UserScript==
  2. // @name 飞书妙记-下载字幕和txt
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-02-22
  5. // @description 让你更加便捷地下载飞书妙记生成的字幕文件和txt文件.
  6. // @author You
  7. // @match https://*.feishu.cn/minutes/*
  8. // @icon http://feishu.cn/favicon.ico
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. var forceDownload = function (blob, filename) {
  16. var a = document.createElement('a');
  17. a.download = filename;
  18. a.href = blob;
  19. a.click();
  20. }
  21.  
  22. let format_map = {
  23. '2': '.txt',
  24. '3': '.srt'
  25. };
  26.  
  27. var downloadRes = function (sid, filename, format) {
  28. fetch(`https://${location.host}/minutes/api/export?_t=${new Date().getTime()}`, {
  29. "headers": {
  30. "accept": "application/json, text/plain, */*",
  31. "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
  32. "bv-csrf-token": "850d44eb-1a84-432b-9de1-b34f715f9d25",
  33. "cache-control": "no-cache",
  34. "content-type": "application/x-www-form-urlencoded",
  35. "device-id": "7338560823671504898",
  36. "platform": "web",
  37. "pragma": "no-cache",
  38. "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Microsoft Edge\";v=\"120\"",
  39. "sec-ch-ua-mobile": "?0",
  40. "sec-ch-ua-platform": "\"Windows\"",
  41. "sec-fetch-dest": "empty",
  42. "sec-fetch-mode": "cors",
  43. "sec-fetch-site": "same-origin",
  44. "utc-bias": "480",
  45. "x-lgw-os-type": "1",
  46. "x-lgw-terminal-type": "2",
  47. "cookie": `${document.cookie}`,
  48. "Referer": `${location.href}`,
  49. "Referrer-Policy": "strict-origin-when-cross-origin"
  50. },
  51. "body": `add_speaker=false&add_timestamp=false&format=${format}&is_fluent=false&language=zh_cn&object_token=${sid}&translate_lang=default`,
  52. "method": "POST"
  53. })
  54. .then(response => response.blob())
  55. .then(blob => {
  56. let blobUrl = window.URL.createObjectURL(blob);
  57. let download_name = filename + format_map[format];
  58. forceDownload(blobUrl, download_name);
  59. })
  60. .catch(e => console.error(e));
  61.  
  62. // .then(response => response.text())
  63. // .then(data => console.log(data));
  64. };
  65.  
  66. if (location.href.includes('/me')) {
  67. window.onload = function () {
  68. // 你的代码放在这里,会在页面加载完成后执行
  69. console.log("页面已完全加载");
  70. let videos = document.querySelectorAll("#app > div > div.mm-layout > div.mm-content-outside > div.mm-content > div.list-table > div > div > a > div");
  71.  
  72. for (var i = 0; i < videos.length; i++) {
  73.  
  74. let parentDiv = videos[i];
  75. var children = parentDiv.children;
  76. var newDiv = document.createElement('div');
  77.  
  78. let sid = parentDiv.parentElement.href.split('minutes/')[1];
  79. let filename = parentDiv.children[0].children[1].querySelector('.content').innerText;
  80.  
  81. var button_txt = document.createElement('button');
  82. button_txt.style.backgroundColor = 'blue';
  83. button_txt.style.color = 'white'; // 设置字体颜色为白色
  84. button_txt.style.fontSize = '14px';
  85. button_txt.textContent = '下载文本';
  86. button_txt.onclick = function (e) {
  87. e.stopPropagation();
  88. e.preventDefault(); // 阻止默认行为
  89. downloadRes(sid, filename, '2');
  90. }
  91.  
  92. var button_srt = document.createElement('button');
  93. button_srt.style.backgroundColor = 'red';
  94. button_srt.style.color = 'white'; // 设置字体颜色为白色
  95. button_srt.style.fontSize = '14px';
  96. button_srt.textContent = '下载字幕';
  97. button_srt.onclick = function (e) {
  98. e.stopPropagation();
  99. e.preventDefault(); // 阻止默认行为
  100. downloadRes(sid, filename, '3');
  101. }
  102.  
  103. newDiv.appendChild(button_txt);
  104. newDiv.appendChild(button_srt);
  105.  
  106. var penultimateChild = children[children.length - 2];
  107. // 在倒数第二个子元素之前插入新div
  108. parentDiv.insertBefore(newDiv, penultimateChild.nextSibling);
  109. }
  110. };
  111.  
  112. return;
  113. }
  114.  
  115. let sid = location.href.split('minutes/')[1];
  116. console.log(`sid:${sid}`);
  117.  
  118. // Create a floating button
  119. var button_txt = document.createElement('button');
  120. button_txt.style.position = 'fixed';
  121. button_txt.style.top = '78px';
  122. button_txt.style.right = '20px';
  123. button_txt.style.backgroundColor = 'blue';
  124. button_txt.style.color = 'white'; // 设置字体颜色为白色
  125. button_txt.style.fontSize = '14px';
  126. button_txt.textContent = '下载文本';
  127. document.body.appendChild(button_txt);
  128.  
  129. // Add click event listener to the button
  130. button_txt.addEventListener('click', function () {
  131. let filename = document.querySelector("div.larkw-web-header-caption-head-title-edit-text.larkw-web-header-caption-head-title-edit-text-allow-edit > span").innerText;
  132. downloadRes(sid, filename, '2');
  133. });
  134.  
  135. var button_srt = document.createElement('button');
  136. button_srt.style.position = 'fixed';
  137. button_srt.style.top = '100px';
  138. button_srt.style.right = '20px';
  139. button_srt.style.backgroundColor = 'red';
  140. button_srt.style.color = 'white'; // 设置字体颜色为白色
  141. button_srt.style.fontSize = '14px';
  142. button_srt.textContent = '下载字幕';
  143. document.body.appendChild(button_srt);
  144.  
  145. // Add click event listener to the button
  146. button_srt.addEventListener('click', function () {
  147. let filename = document.querySelector("div.larkw-web-header-caption-head-title-edit-text.larkw-web-header-caption-head-title-edit-text-allow-edit > span").innerText;
  148. downloadRes(sid, filename, '3');
  149. });
  150.  
  151. })();

QingJ © 2025

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