show link on dood playlist

script to display links on doodstream playlist

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         show link on dood playlist
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  script to display links on doodstream playlist
// @author       vallerydelexy
// @match        https://dood.to/f/*
// @match        https://dood.so/f/*
// @match        https://dood.wf/f/*
// @match        https://dood.re/f/*
// @match        https://dood.la/f/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=dood.re
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    // show links
    var links = []
    var as = document.querySelectorAll('a')
    as.forEach((a)=>{
        links.push(a.href)
    })
    var link = new Set(links)
    var strlink = Array.from(link).reduce((a, b) => { return a + b + " " }, "")

    // show size
    function toBytes(size, type)
    {
        const types = ["B", "KB", "MB", "GB", "TB"];
        const key = types.indexOf(type.toUpperCase())
        if (typeof key !== "boolean") {
            return size * 1024 ** key;
        }
        return "invalid type: type must be GB/KB/MB etc.";
    }
    function bytesToSize(bytes) {
        const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
        if (bytes === 0) return 'n/a'
        const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10)
        if (i === 0) return `${bytes} ${sizes[i]})`
  return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`
    }
    let names = Array.from(document.querySelectorAll(".name"))
    let totalSize = 0
    let totalFile = 0
    names.forEach((name)=>{
        let span = name.querySelector("span")
        let currentSizeFromText = span.innerText.split(" ")
        let currentSize = toBytes(currentSizeFromText[0],currentSizeFromText[1])
        totalSize += currentSize
        totalFile++
    })
    const readableSize = "\n\n"+bytesToSize(totalSize)
    // render to the page
    const wrappernode = document.createElement("p")
    const sizewrapper = document.createElement("h2")
    wrappernode.style = "font-size: 6px;"
    sizewrapper.style = "color:#f90;"
    sizewrapper.classList.add("font-weight-bold");
    sizewrapper.classList.add("text-center");
    const textnode = document.createTextNode(strlink)
    const sizenode = document.createTextNode(readableSize + " | " + totalFile + " Video")
    wrappernode.appendChild(textnode)
    sizewrapper.appendChild(sizenode)
    document.querySelector('h1').parentNode.appendChild(sizewrapper)
    document.querySelector('h1').parentNode.appendChild(wrappernode)
})();