Greasy Fork

Greasy Fork is available in English.

抖音视频下载插件

帮助用户拦截部分恶意网页

当前为 2022-12-30 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         抖音视频下载插件
// @namespace    https://space.bilibili.com/1552375363
// @version      1.71
// @description  帮助用户拦截部分恶意网页
// @author       Xbodw
// @match        https://*
// @match        http://*
// @match        ftp://*
// @match        *://*/*
// @icon         https://tse3-mm.cn.bing.net/th/id/OIP-C.nncnWjuyFBadY1Nl0PqDDwAAAA?pid=ImgDet&rs=1
// @grant        unsafeWindow
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    if(window.location.host == "www.douyin.com") {
     var dylogo = document.querySelector('a[href="//www.douyin.com/"]');
     dylogo.remove();
     var button = document.createElement("input"); //创建一个input对象(提示框按钮)
     button.setAttribute("type", "button");
     button.setAttribute("value", "下载");
     button.style.width = "50px";
     button.style.align = "center";
     button.style.background = "#000000";
     button.style.color = "white";
     button.style.visibility = 'visible';
     button.style.border="1px solid red";
     button.onclick = function() {
         if(window.location.host == "www.douyin.com") {}
         else {
             alert("网站可能不是抖音!");
             return;
         }
        var link = document.querySelector('source[src*="&aid="]').getAttribute('src');
     var part = document.querySelector('source[src*="&aid="]').parentElement.getAttribute('mediatype');
     if(part == "video") {
      //var link=document.querySelector('source[src*="id="][src*="v3-web"]').getAttribute('src');
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      var hour = date.getHours();
      var minute = date.getMinutes();
      var second = date.getSeconds();
      var filename="视频_" + year + month + day + hour + minute + second + ".mp4";
      console.log("视频正在合成,完成后将自动保存.");fetch(link).then(res => res.blob()).then(blob => {
      const a = document.createElement('a');
      document.body.appendChild(a)
      a.style.display = 'none'
      const url = window.URL.createObjectURL(blob);
      a.href = url;
      a.download = filename;
      a.click();
      document.body.removeChild(a)
      window.URL.revokeObjectURL(url);
      });
     } else {
         alert("获取视频下载链接失败,可能是接口在维护或脚本版本过低!");
     }
    }
        if(window.location.href == "https://www.douyin.com/") {
         var getdiv = document.querySelector('div[class="iViO9oMI"]');
         getdiv.remove();
         getdiv = document.querySelector('div[class="HQwsRJFy"]');
         getdiv.appendChild(button);
        }
        if(window.location.href.indexOf("https://www.douyin.com/video/") !== -1) {
         var getdiv7 = document.querySelector('div[class="iViO9oMI"]');
         getdiv7.remove();
         var getdiv8 = document.querySelector('div[class="HQwsRJFy"]');
         getdiv8.appendChild(button);
        }
        if(window.location.href.indexOf("https://www.douyin.com/search/") !== -1) {
         var getdiv5 = document.querySelector('div[class="iViO9oMI"]');
         var getdiv6 = getdiv5.parentNode;
         getdiv5.remove();
         getdiv6.appendChild(button);
        }
        if(window.location.href.indexOf("modal_id=") !== -1) {
         var getdiv3 = document.querySelector('div[class="btn"]');
         var getdiv4 = getdiv3.parentNode;
         getdiv3.remove();
         getdiv4.appendChild(button);
        }
    }
})();