Cobalt Tools Video Downloader

Adds a context menu item that downloads the current page's video.

  1. // ==UserScript==
  2. // @name Cobalt Tools Video Downloader
  3. // @description Adds a context menu item that downloads the current page's video.
  4. // @version 1.0.3
  5. // @author yodaluca23
  6. // @license GNU GPLv3
  7. // @grant GM_registerMenuCommand
  8. // @grant GM_openInTab
  9. // @run-at document-idle
  10. // @inject-into content
  11. // @match *://*cobalt.tools/*
  12. // @match *://*.bilibili.com/*
  13. // @match *://app.bsky.social/*
  14. // @match *://www.dailymotion.com/*
  15. // @match *://*.facebook.com/*
  16. // @match *://fb.watch/*
  17. // @match *://*.instagram.com/*
  18. // @match *://ddinstagram.com/*
  19. // @match *://www.loom.com/*
  20. // @match *://ok.ru/*
  21. // @match *://www.pinterest.com/*
  22. // @match *://*.reddit.com/*
  23. // @match *://rutube.ru/*
  24. // @match *://*.snapchat.com/*
  25. // @match *://soundcloud.com/*
  26. // @match *://streamable.com/*
  27. // @match *://*.tiktok.com/*
  28. // @match *://*.tumblr.com/*
  29. // @match *://*.twitch.tv/*
  30. // @match *://twitter.com/*
  31. // @match *://mobile.twitter.com/*
  32. // @match *://x.com/*
  33. // @match *://vxtwitter.com/*
  34. // @match *://fixvx.com/*
  35. // @match *://vine.co/*
  36. // @match *://vimeo.com/*
  37. // @match *://*.vk.com/*
  38. // @match *://www.youtube.com/*
  39. // @match *://music.youtube.com/*
  40. // @match *://m.youtube.com/*
  41. // @match *://*.xiaohongshu.com/*
  42. // @match *://*.xhslink.com/*
  43. // @namespace https://gf.qytechs.cn/users/1315976
  44. // ==/UserScript==
  45.  
  46. let cobaltInitialInjectDelay = 2000; // Cobalt Initial delay in milliseconds
  47.  
  48. function isCobaltURL() {
  49. return (window.location.href.includes("cobalt.tools"));
  50. }
  51.  
  52. function waitForLoadingComplete(element) {
  53. return new Promise((resolve) => {
  54. const checkLoadingState = setInterval(() => {
  55. const icon = document.querySelector(element);
  56.  
  57. if (icon && !icon.className.includes("loading")) {
  58. clearInterval(checkLoadingState);
  59. resolve();
  60. }
  61. }, 100);
  62. });
  63. }
  64.  
  65. function waitForSaveDownloadButton() {
  66. return new Promise((resolve) => {
  67. const checkButtonState = setInterval(() => {
  68. const button = document.querySelector("#button-save-download");
  69.  
  70. if (button) {
  71. clearInterval(checkButtonState);
  72. resolve();
  73. }
  74. }, 100);
  75. });
  76. }
  77.  
  78. function cobaltWebsiteSimulation() {
  79. // Function to check if input length is greater than 5
  80. if (window.document.getElementById('link-area').value.length > 5) {
  81. document.getElementById('download-button').click();
  82. waitForSaveDownloadButton().then(() => {
  83. document.querySelector("#button-save-download").click()
  84. // close the cobalt tab
  85. setTimeout(() => {
  86. window.close();
  87. }, 1000);
  88. });
  89. }
  90. }
  91.  
  92. if (isCobaltURL()) {
  93. setTimeout(() => {
  94. waitForLoadingComplete("#input-icons").then(() => {
  95. cobaltWebsiteSimulation();
  96. });
  97. }, cobaltInitialInjectDelay);
  98. }
  99.  
  100. function openCobalt() {
  101. GM_openInTab("https://cobalt.tools/#" + window.location.href, true);
  102. alert("Loading, please wait... \nOpening cobalt tools website and automating download actions.")
  103. }
  104.  
  105. GM_registerMenuCommand("Download this video with Cobalt Tools", openCobalt);

QingJ © 2025

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