spider4Douyin

用于提取当前视频的地址

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name spider4Douyin
// @version 0.1.0
// @author hyddg
// @description 用于提取当前视频的地址
// @homepage https://greasyfork.org/zh-CN/scripts/961591
// @match *://www.douyin.com/discover*,
// @match *://www.douyin.com/user/*
// @name:en rapidupload-userscript
// @namespace moe.cangku.111
// @homepageURL https://greasyfork.org/zh-CN/scripts/961591
// @contributionURL https://afdian.net/@mengzonefire
// @description:en input bdlink to get files or get bdlink for Baidu™ WebDisk.
// @compatible firefox Violentmonkey
// @compatible firefox Tampermonkey
// @compatible chrome Violentmonkey
// @compatible chrome Tampermonkey
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_setClipboard
// @grant GM_getResourceText
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// @require https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js

// ==/UserScript==
(function(){
    window.addEventListener('load',function(){
        var videoUrls="";
        const actionButtons=$("<span class='acionBars'></span>");
        var copyUrlButton=$('<span>点我复制视频地址</span>');
        copyUrlButton.click(function(){
            const url=$("video>source").attr("src");
            if(!url){
                alert("当前页面不存在视频");
                return;
            }
            videoUrls=videoUrls+"https:"+$("video>source").attr("src")+"\n";
            console.log("videoUrls:",videoUrls)
        });
        const clearButton=$('<span>点我清除已复制视频地址</span>');
        clearButton.click(function (){
            videoUrls="";
        });
        var downloadUrlButton=$("<span>点我下载已复制的视频地址</span>");
        downloadUrlButton.click(function(){
            var textFileAsBlob = new Blob([videoUrls], {type:'text/plain'});
            var downloadLink = document.createElement("a");
            downloadLink.download = 'test.txt';
            downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
            downloadLink.click();
        });

        //给创建的按钮添加css
        $("#root").append(actionButtons);
        $(actionButtons).append(copyUrlButton).append(clearButton).append(downloadUrlButton);
        actionButtons.css({'position':"fixed","top":"100px","left":"40px","color":"red",'border':'1px solid yellow',"z-index":999,'padding':'4px 0'});
        $('.acionBars>span').css({'border':'1px solid red','border-radius':'10px','margin-right':'10px'});
        $('.acionBars>span:last-child').css({'margin-right':'0'});
    });
})()