dp-vids.com helper

A script that lets you download videos with the click of a button and hide private videos.

当前为 2024-11-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        dp-vids.com helper
// @namespace   Violentmonkey Scripts
// @match       https://dp-vids.com/*
// @match       https://pnt-vids.com/*
// @grant       none
// @version     1.4
// @author      Penomancer
// @description A script that lets you download videos with the click of a button and hide private videos.
// @license MIT
// ==/UserScript==

(function waitForPageContext(callback, interval = 100) {
    const checkPageContext = setInterval(() => {
        if (typeof window.pageContext !== 'undefined') {
            clearInterval(checkPageContext);
            callback(); // Call the callback function when pageContext is defined
        }
    }, interval);



})(function() {
    'use strict';
    console.log("Starting Script")

    const originalFetch = window.fetch;
    let downloadLink = '';
    let downloadLinkToUse = '';
    let videoSrc = '';
    let newTabLink = '';
    const downloadLinkStarter = 'https://dp-vids.com/contents/videos/';
    const downloadLinkStarterPnt = 'https://pnt-vids.com/contents/videos/';
    const videoTitle = document.title;
    const targetClass = 'line-private';
    const regex = /\/(\d+\/\d+\/\d+\.mp4\/)$/;


    function addDownloadButton(downloadLink) {
        console.log("Download link for button:", downloadLink)
        const tabsMenu = document.querySelector('.tabs-menu');
        if (tabsMenu) {
            const tabsMenuList = tabsMenu.querySelector('ul');
            const newTab = document.createElement('li');
            tabsMenuList.prepend(newTab);

            const linkElement = document.createElement('a');
            linkElement.textContent = 'Download';
            linkElement.href = downloadLink;
            linkElement.target = '_blank';
            linkElement.className = "toggle-button"
            linkElement.download = videoTitle
            newTab.appendChild(linkElement);
        } else {
            console.error("Parent element not found.");
        }
    }

    function removeTargetDivs() {
        const divs = document.querySelectorAll(`.${targetClass}`);
        divs.forEach(div => div.remove());
    }



    if (window.location.href.includes("/videos") || window.location.href.includes("/video") ) {
    console.log("Videos Found")
    const noPlayerElements = document.querySelectorAll('.no-player');
    if (noPlayerElements.length > 0) {
      console.log("Found 'no-player' elements on the page.");

    } else {
      console.log("Didn't find no-player elements on the page.")
    }
const jsonLdScript = document.querySelector('script[type="application/ld+json"]');

if (jsonLdScript) {
    try {
        const jsonData = JSON.parse(jsonLdScript.textContent);

        const videoName = jsonData.name;
        const videoDescription = jsonData.description;
        const thumbnailUrl = jsonData.thumbnailUrl;
        const uploadDate = jsonData.uploadDate;
        const duration = jsonData.duration;
        const contentUrl = jsonData.contentUrl;

        console.log("Video Name:", videoName);
        console.log("Description:", videoDescription);
        console.log("Thumbnail URL:", thumbnailUrl);
        console.log("Upload Date:", uploadDate);
        console.log("Duration:", duration);
        console.log("Content URL:", contentUrl);

        downloadLink = contentUrl
    } catch (error) {
        console.error("Error parsing JSON-LD data:", error);
    }
} else {
    console.error("JSON-LD script tag not found.");
}
const match = downloadLink.match(regex);
    let extractedPart = match[1]; // This will give you the '8000/8024/8024.mp4/'
    extractedPart = extractedPart.slice(0, -1);
    if (window.location.href.includes("dp")){
    downloadLink = downloadLinkStarter + extractedPart
        } else {
      downloadLink = downloadLinkStarterPnt + extractedPart
    }
    console.log("Extracted part:", extractedPart);


    console.log("Download Link:", downloadLink)

    addDownloadButton(downloadLink);
                }

        removeTargetDivs();
        const observer = new MutationObserver(removeTargetDivs);
        observer.observe(document.body, { childList: true, subtree: true, attributes: true });

})();