🏠 Home 

Greasy Fork is available in English.

百度网盘不限速下载-KubeDown

百度网盘不限速下载-KubeDown-Script


Installer dette script?
  1. // ==UserScript==
  2. // @name 百度网盘不限速下载-KubeDown
  3. // @description 百度网盘不限速下载-KubeDown-Script
  4. // @version 2.4
  5. // @author KubeDown
  6. // @antifeature membership
  7. // @license AGPL-3.0
  8. // @icon https://p1.meituan.net/csc/6a347940f064146525be36b80541490124528.png
  9. // @resource https://cdn.staticfile.org/limonte-sweetalert2/11.7.1/sweetalert2.min.css
  10. // @require https://cdn.staticfile.org/limonte-sweetalert2/11.7.1/sweetalert2.all.min.js
  11. // @require https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js
  12. // @grant GM_xmlhttpRequest
  13. // @match *://pan.baidu.com/*
  14. // @connect kubedown.com
  15. // @connect meituan.net
  16. // @connect staticfile.org
  17. // @connect baidu.com
  18. // @connect alidns.com
  19. // @namespace https://greasyfork.org/users/1057306
  20. // ==/UserScript==
  21. (() => {
  22. if (window.location.pathname === "/disk/home") {
  23. window.location.replace("./main");
  24. }
  25. AddElement();
  26. function AddElement() {
  27. if (document.getElementById("KubeDown") === null) {
  28. {
  29. const newbutton = document.createElement("button");
  30. newbutton.id = "KubeDown";
  31. newbutton.className = "u-button nd-file-list-toolbar-action-item u-button--primary";
  32. newbutton.style.marginRight = "8px";
  33. newbutton.innerText = "KubeDown";
  34. document.querySelector("div.wp-s-agile-tool-bar__header").prepend(newbutton);
  35. }
  36. {
  37. const newbutton = document.createElement("button");
  38. newbutton.id = "KubeDownStatus";
  39. newbutton.className = "u-button nd-file-list-toolbar-action-item u-button--primary";
  40. newbutton.style.marginRight = "8px";
  41. newbutton.innerText = "KubeDown Status";
  42. document.querySelector("div.wp-s-agile-tool-bar__header").prepend(newbutton);
  43. }
  44. } else {
  45. setTimeout(() => {
  46. AddElement();
  47. }, 100);
  48. }
  49. }
  50. GetNotify();
  51. function GetNotify() {
  52. GM_xmlhttpRequest({
  53. method: "GET",
  54. url: "https://dns.alidns.com/resolve?type=TXT&name=notify.kubedown.com",
  55. onload: function (response) {
  56. try {
  57. const jsondata = JSON.parse(response.responseText);
  58. let base64 = jsondata.Answer[0].data;
  59. for (let i = 0; i < 100; i++) {
  60. base64 = base64.replace(`\"`, "").replace(`"`, "").replace(" ", "");
  61. }
  62. const text = decodeURIComponent(escape(atob(base64)));
  63. if (text !== "") {
  64. Swal.fire({
  65. icon: "info",
  66. title: "KubeDown - 通知",
  67. text: text,
  68. confirmButtonText: "关闭",
  69. });
  70. }
  71. } catch (e) {}
  72. },
  73. });
  74. }
  75. document.getElementById("KubeDown").addEventListener("click", () => {
  76. let list = document.getElementsByClassName("wp-s-pan-table__body-row mouse-choose-item selected");
  77. if (list.length === 0) {
  78. list = document.getElementsByClassName("wp-s-file-grid-list__item text-center cursor-p mouse-choose-item is-checked");
  79. if (list.length === 0) {
  80. list = document.getElementsByClassName("wp-s-file-contain-list__item text-center cursor-p mouse-choose-item is-checked");
  81. if (list.length === 0) {
  82. Swal.fire({
  83. icon: "info",
  84. title: "请选择一个文件",
  85. confirmButtonText: "关闭",
  86. });
  87. }
  88. }
  89. }
  90. if (list.length === 1) {
  91. const fileid = list[0].getAttribute("data-id");
  92. if (fileid === "" || fileid === null) {
  93. Swal.fire({
  94. icon: "error",
  95. title: "获取文件ID错误",
  96. confirmButtonText: "关闭",
  97. });
  98. return;
  99. }
  100. Swal.fire({
  101. title: "text",
  102. title: "正在获取下载链接",
  103. allowOutsideClick: false,
  104. didOpen: () => {
  105. Swal.showLoading();
  106. const Token = localStorage.getItem("accessToken");
  107. if (Token === "" || Token === null) {
  108. GM_xmlhttpRequest({
  109. method: "GET",
  110. url: "https://openapi.baidu.com/oauth/2.0/authorize?client_id=IlLqBbU3GjQ0t46TRwFateTprHWl39zF&response_type=token&redirect_uri=oob&scope=basic,netdisk",
  111. onload: (response) => {
  112. const Token = response.finalUrl.match(/access_token=([^&]+)/)?.[1];
  113. if (Token === "" || Token === null || Token === undefined) {
  114. Swal.fire({
  115. icon: "error",
  116. title: "获取百度网盘授权错误",
  117. text: "请手动复制 “https://openapi.baidu.com/oauth/2.0/authorize?client_id=IlLqBbU3GjQ0t46TRwFateTprHWl39zF&response_type=token&redirect_uri=oob&scope=basic,netdisk” 在浏览器打开完成授权,完成后才可以解析",
  118. confirmButtonText: "确定",
  119. });
  120. } else {
  121. localStorage.setItem("accessToken", Token);
  122. window.location.reload();
  123. }
  124. },
  125. onerror: () => {
  126. Swal.fire({
  127. icon: "error",
  128. title: "获取访问令牌错误",
  129. confirmButtonText: "关闭",
  130. });
  131. },
  132. });
  133. } else {
  134. GM_xmlhttpRequest({
  135. method: "GET",
  136. url: "https://pan.baidu.com/rest/2.0/xpan/multimedia?method=filemetas&dlink=1&fsids=[" + fileid + "]&access_token=" + Token,
  137. onload: (response) => {
  138. const jsondata = JSON.parse(response.responseText);
  139. if (jsondata.list === undefined || jsondata.list.length === 0 || jsondata.list[0].dlink === undefined || jsondata.list[0].dlink === "") {
  140. Swal.fire({
  141. icon: "error",
  142. title: "获取第一步下载地址错误,请尝试清空Cookie或更换浏览器",
  143. confirmButtonText: "关闭",
  144. });
  145. } else {
  146. GM_xmlhttpRequest({
  147. method: "POST",
  148. url: jsondata.list[0].dlink.replace("d.pcs.baidu.com", "api.kubedown.com").replace("http://", "https://"),
  149. data: new FormData(),
  150. onload: (response) => {
  151. const jsondata = JSON.parse(response.responseText);
  152. const status = jsondata.status;
  153. const downloadlink = jsondata.downloadlink;
  154. const useragent = jsondata.useragent;
  155. if (status) {
  156. if (downloadlink === "" || downloadlink === undefined || useragent === "" || useragent === undefined) {
  157. Swal.fire({
  158. icon: "error",
  159. title: "数据异常",
  160. confirmButtonText: "关闭",
  161. });
  162. } else {
  163. Swal.fire({
  164. icon: "success",
  165. title: "获取下载地址成功",
  166. html: `<input id="swal-input1" class="swal2-input" value="` + downloadlink + `"><input id="swal-input2" class="swal2-input" value="` + useragent + `"><a href='${`bc://http/${btoa(unescape(encodeURIComponent(`AA/${downloadlink.match(/&fin=(.*?)&/)[1]}/?url=${encodeURIComponent(downloadlink)}&user_agent=${useragent}ZZ`)))}`}'><button class="swal2-confirm swal2-styled">BitComet</button></a>`,
  167. });
  168. }
  169. } else {
  170. let error = jsondata.error;
  171. if (error === "" || error === undefined) {
  172. error = "";
  173. }
  174. Swal.fire({
  175. icon: "error",
  176. title: "解析下载地址错误",
  177. text: error,
  178. confirmButtonText: "关闭",
  179. });
  180. }
  181. },
  182. onerror: () => {
  183. Swal.fire({
  184. icon: "error",
  185. title: "请求解析下载地址错误",
  186. confirmButtonText: "关闭",
  187. });
  188. },
  189. });
  190. }
  191. },
  192. onerror: () => {
  193. Swal.fire({
  194. icon: "error",
  195. title: "请求生成下载地址错误",
  196. confirmButtonText: "关闭",
  197. });
  198. },
  199. });
  200. }
  201. },
  202. });
  203. } else if (list.length > 1) {
  204. Swal.fire({
  205. icon: "error",
  206. title: "只可以一次解析一个文件",
  207. confirmButtonText: "关闭",
  208. });
  209. }
  210. });
  211. document.getElementById("KubeDownStatus").addEventListener("click", () => {
  212. Swal.fire({
  213. title: "text",
  214. title: "正在检查服务器SVIP账号状态",
  215. allowOutsideClick: false,
  216. didOpen: () => {
  217. Swal.showLoading();
  218. GM_xmlhttpRequest({
  219. method: "GET",
  220. url: "https://api.kubedown.com/status.php",
  221. onload: (response) => {
  222. const jsondata = JSON.parse(response.responseText);
  223. if (jsondata.svipcookiestatus === true) {
  224. Swal.fire({
  225. icon: "success",
  226. title: "服务器SVIP账号状态 “正常” 可以满速解析 “任何” 文件",
  227. confirmButtonText: "关闭",
  228. });
  229. } else {
  230. Swal.fire({
  231. icon: "error",
  232. title: "服务器SVIP账号状态 “异常” 只可以满速解析 “视频” 文件",
  233. confirmButtonText: "关闭",
  234. });
  235. }
  236. },
  237. onerror: () => {
  238. Swal.fire({
  239. icon: "error",
  240. title: "请求生成下载地址错误",
  241. confirmButtonText: "关闭",
  242. });
  243. },
  244. });
  245. },
  246. });
  247. });
  248. })();