ddrk-download

低端影视-下载

当前为 2023-01-27 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ddrk-download
// @namespace    https://github.com/Mrbunker/ddrk-download
// @version      0.0.2
// @author       mission522
// @description  低端影视-下载
// @license      MIT
// @icon         https://ddys.art/favicon-32x32.png
// @match        *://*.ddys.tv/*
// @match        *://*.ddys.art/*
// @match        *://*.ddys.pro/*
// @match        *://*.ddys2.me/*
// @match        *://*.ddys.me/*
// ==/UserScript==

(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}");

(function() {
  "use strict";
  const style = "";
  async function main() {
    var _a;
    const wpScript = (_a = document.querySelector("script.wp-playlist-script")) == null ? void 0 : _a.innerHTML;
    if (!wpScript)
      return;
    const popup = createPopup();
    createBtn(popup, wpScript);
  }
  function createPopup() {
    const popup = document.createElement("div");
    document.body.appendChild(popup);
    popup.classList.add("ddd-popup");
    popup.style.display = "none";
    return popup;
  }
  function createBtn(popup, wpScript) {
    const app = document.createElement("span");
    app.classList.add("ddd-btn");
    app.innerHTML = "下载";
    let firtClick = true;
    app.addEventListener("click", async () => {
      popup.style.display = popup.style.display === "none" ? "block" : "none";
      if (!firtClick)
        return;
      const data = await download(wpScript);
      const popupStr = data.map(
        (item) => `<div><span>${item == null ? void 0 : item.ep}</span> <a href="${(item == null ? void 0 : item.video) ? item == null ? void 0 : item.video : "无"}" >链接</a></div>`
      ).join("");
      popup.innerHTML = popupStr;
      firtClick = false;
    });
    const appWrap = document.querySelector(`.entry>p [style="float:right;"]:not([class])`);
    appWrap.innerHTML = "";
    appWrap == null ? void 0 : appWrap.appendChild(app);
  }
  async function download(wpScript) {
    const tracks = JSON.parse(wpScript).tracks;
    const resources = tracks.map((item) => {
      const regResult = item.src0.match(/^\/v\/((\w*)\/(.*))/);
      return {
        name: regResult ? regResult[1] : "匹配失败",
        ep: item.caption,
        catalog: regResult ? regResult[2] : "匹配失败",
        src1: `${window.location.origin}/getvddr/video?id=${item.src1}&type=mix`
      };
    });
    return await Promise.all(
      resources.map(async (item) => {
        const res = await fetch(item.src1);
        const resJson = await res.json();
        const video = (resJson == null ? void 0 : resJson.url) ? resJson == null ? void 0 : resJson.url.replace("=1", item.name) : void 0;
        return {
          name: item.name,
          ep: item.ep,
          catalog: item.catalog,
          video,
          cache: resJson == null ? void 0 : resJson.cache
        };
      })
    );
  }
  main();
})();