低端影视-下载

下载

当前为 2022-11-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 低端影视-下载
  3. // @namespace https://github.com/Mrbunker/ddrk-download
  4. // @version 0.0.1
  5. // @author mission522
  6. // @description 下载
  7. // @license MIT
  8. // @icon https://ddys.tv/favicon-32x32.png
  9. // @match *://*.ddys.tv/*
  10. // @match *://*.ddys2.me/*
  11. // ==/UserScript==
  12.  
  13. (d=>{const o=document.createElement("style");o.dataset.source="vite-plugin-monkey",o.innerText=d,document.head.appendChild(o)})(".ddd-btn{color:#fff;padding:0 15px;cursor:pointer;color:#00b09a}.ddd-btn:hover{color:#006457;text-decoration:underline}.ddd-popup{min-width:100px;min-height:100px;padding:20px;border-radius:20px 0 0;box-shadow:#848484 -1px -1px 8px;background-color:#fff;z-index:998;position:fixed;bottom:0;right:0;transition:all}#afc_sidebar_2842,#iaujwnefhw,#sajdhfbjwhe{position:fixed!important;right:20000px!important}");
  14.  
  15. (function() {
  16. "use strict";
  17. const style = "";
  18. async function main() {
  19. var _a;
  20. const wpScript = (_a = document.querySelector("script.wp-playlist-script")) == null ? void 0 : _a.innerHTML;
  21. if (!wpScript)
  22. return;
  23. const popup = createPopup();
  24. createBtn(popup, wpScript);
  25. }
  26. function createPopup() {
  27. const popup = document.createElement("div");
  28. document.body.appendChild(popup);
  29. popup.classList.add("ddd-popup");
  30. popup.style.display = "none";
  31. return popup;
  32. }
  33. function createBtn(popup, wpScript) {
  34. const app = document.createElement("span");
  35. app.classList.add("ddd-btn");
  36. app.innerHTML = "下载";
  37. let firtClick = true;
  38. app.addEventListener("click", async () => {
  39. popup.style.display = popup.style.display === "none" ? "block" : "none";
  40. if (!firtClick)
  41. return;
  42. const data = await download(wpScript);
  43. const popupStr = data.map(
  44. (item) => `<div><span>${item == null ? void 0 : item.ep}</span> <a href="${(item == null ? void 0 : item.video) ? item == null ? void 0 : item.video : "无"}" target="_blank">链接</a></div>`
  45. ).join("");
  46. popup.innerHTML = popupStr;
  47. firtClick = false;
  48. });
  49. const appWrap = document.querySelector(`.entry>p [style="float:right;"]:not([class])`);
  50. appWrap.innerHTML = "";
  51. appWrap == null ? void 0 : appWrap.appendChild(app);
  52. }
  53. async function download(wpScript) {
  54. const tracks = JSON.parse(wpScript).tracks;
  55. const resources = tracks.map((item) => {
  56. const regResult = item.src0.match(/^\/v\/((\w*)\/(.*))/);
  57. return {
  58. name: regResult ? regResult[1] : "匹配失败",
  59. ep: item.caption,
  60. catalog: regResult ? regResult[2] : "匹配失败",
  61. src1: `${window.location.origin}/getvddr/video?id=${item.src1}&type=mix`
  62. };
  63. });
  64. return await Promise.all(
  65. resources.map(async (item) => {
  66. const res = await fetch(item.src1);
  67. const resJson = await res.json();
  68. const video = (resJson == null ? void 0 : resJson.url) ? resJson == null ? void 0 : resJson.url.replace("=1", item.name) : void 0;
  69. return {
  70. name: item.name,
  71. ep: item.ep,
  72. catalog: item.catalog,
  73. video,
  74. cache: resJson == null ? void 0 : resJson.cache
  75. };
  76. })
  77. );
  78. }
  79. main();
  80. })();