// ==UserScript== // @name 💯 懒人专用系列 ——— 视频下载 // @namespace lr-toolbox-VideoDownload // @version 1.0.5 // @description ⭕支持下载B站(bilibili),抖音,快手,西瓜视频,Youtube等网站视频。❌拒绝收费。⭕持续更新。 // @author lanhaha // @icon https://lf1-cdn-tos.bytegoofy.com/goofy/ies/douyin_web/public/favicon.ico // @match *://*.douyin.com/* // @match *://*.kuaishou.com/* // @match *://*.ixigua.com/* // @match *://*.bilibili.com/* // @match *://*.youtube.com/* // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/crypto-js/4.1.1/crypto-js.min.js // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_download // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @connect iesdouyin.com // @connect 47.99.158.118 // ==/UserScript== /* *********************************************************** 应Greasyfork.org网站规则要求, 懒人脚本将视频解析、音乐下载、视频下载等功能拆分为多个脚本: https://greasyfork.org/zh-CN/scripts/467776 https://greasyfork.org/zh-CN/scripts/469604 https://greasyfork.org/zh-CN/scripts/469689 https://greasyfork.org/zh-CN/scripts/468015 https://greasyfork.org/zh-CN/scripts/469521 可自行分别安装。 *********************************************************** */ (function() { 'use strict'; /*--config--*/ var Config ={ couponUrl:window.location.href, couponHost:window.location.host, isMobile:/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent), iconVipTop:360, iconVipPosition : 'left', iconVipWidth : 40, couponTimerNum : 100,//100次等于10秒 couponWaitTime : 100, iconWaitTime : 100, iconVipOpacity:100, selectedLeft:'selected', selectedRight:'', dyVideoDownload:GM_getValue('dyVideoDownload',22), ksVideoDownload:GM_getValue('ksVideoDownload',22), xiguaVideoDownload:GM_getValue('xiguaVideoDownload',22), biliVideoDownload:GM_getValue('biliVideoDownload',22), youtubeVideoDownload:GM_getValue('youtubeVideoDownload',22), } var {couponUrl, couponHost, isMobile, iconVipTop, iconVipPosition, iconVipWidth, iconVipOpacity, couponTimerNum, couponWaitTime, iconWaitTime, selectedLeft, selectedRight, dyVideoDownload, ksVideoDownload, xiguaVideoDownload, biliVideoDownload, youtubeVideoDownload } = Config; /*--lang--*/ var lang = { videoDownload:'设置', dyVideoDownload:'抖音下载', ksVideoDownload:'快手下载', xiguaVideoDownload:'西瓜下载', biliVideoDownload:'B站 (bilibili) 下载', youtubeVideoDownload:'youtube下载', }; var videoDownload = [ {funcName:'videoDownload',name:'dyVideoDownload',match:/^https?:\/\/www\.douyin\.com\/?.+$/,isWebOpen:dyVideoDownload}, {funcName:'videoDownload',name:'ksVideoDownload',match:/^https?:\/\/www\.kuaishou\.com\/?.+$/,isWebOpen:ksVideoDownload}, {funcName:'videoDownload',name:'xiguaVideoDownload',match:/^https?:\/\/www\.ixigua\.com\//,isWebOpen:xiguaVideoDownload}, {funcName:'videoDownload',name:'biliVideoDownload',match:/^https?:\/\/www\.bilibili\.com\//,isWebOpen:biliVideoDownload}, {funcName:'videoDownload',name:'youtubeVideoDownload',match:/^https?:\/\/www\.youtube\.com/,isWebOpen:youtubeVideoDownload} ]; var downloadOption = [{name:'直接下载',id:'toDownload'},{name:'复制链接',id:'toCopy'},{name:'打开文件',id:'toLink'}]; /*--create style--*/ var domHead = document.getElementsByTagName('head')[0]; var domStyle = document.createElement('style'); domStyle.type = 'text/css'; domStyle.rel = 'stylesheet'; class BaseClass{ constructor(){ GM_registerMenuCommand("设置", () => this.menuSet()); } menuSet(){ var _this = this; let menuSetStyle = ` .zhmMask{ z-index:999999999; background-color:#000; position: fixed;top: 0;right: 0;bottom: 0;left: 0; opacity:0.8; } .wrap-box{ z-index:1000000000; position:fixed;;top: 50%;left: 50%;transform: translate(-50%, -200px); width: 300px; color: #555; background-color: #fff; border-radius: 5px; overflow:hidden; font:16px numFont,PingFangSC-Regular,Tahoma,Microsoft Yahei,sans-serif !important; font-weight:400 !important; } .setWrapHead{ background-color:#f24443;height:40px;color:#fff;text-align:center;line-height:40px; } .setWrapLi{ margin:0px;padding:0px; } .setWrapLi li{ background-color: #fff; border-bottom:1px solid #eee; margin:0px !important; padding:12px 20px; display: flex; justify-content: space-between;align-items: center; list-style: none; } .setWrapLiContent{ display: flex;justify-content: space-between;align-items: center; } .setWrapSave{ position:absolute;top:-2px;right:10px;font-size:24px;cursor:pointer } .iconSetFoot{ position:absolute;bottom:0px;padding:10px 20px;width:100%; z-index:1000000009;background:#fef9ef; } .iconSetFootLi{ margin:0px;padding:0px; } .iconSetFootLi li{ display: inline-flex; padding:0px 2px; justify-content: space-between;align-items: center; font-size: 12px; } .iconSetFootLi li a{ color:#555; } .iconSetFootLi a:hover { color:#fe6d73; } .iconSetPage{ z-index:1000000001; position:absolute;top:0px;left:300px; background:#fff; width:300px; height:100%; } .iconSetUlHead{ padding:0px; margin:0px; } .iconSetPageHead{ border-bottom:1px solid #ccc; height:40px; line-height:40px; display: flex; justify-content: space-between; align-items: center; background-color:#fe6d73; color:#fff; font-size: 15px; } .iconSetPageLi{ margin:0px;padding:0px; } .iconSetPageLi li{ list-style: none; padding:8px 20px; } .zhihuSetPage{ z-index:1000000002;position:absolute;top:0px;left:300px;background:#fff;width:300px;height:100%; } .iconSetPageInput{ display: flex !important;justify-content: space-between;align-items: center; } .zhihuSetPageLi{ margin:0px;padding:0px; } .zhihuSetPageLi li{ border-bottom:1px solid #eee;padding:12px 20px;display:block; } .zhihuSetPageContent{ display: flex !important;justify-content: space-between;align-items: center; } li:last-child{ border-bottom:none; } .circular{ width: 40px;height: 20px;border-radius: 16px;transition: .3s;cursor: pointer;box-shadow: 0 0 3px #999 inset; } .round-button{ width: 20px;height: 20px;;border-radius: 50%;box-shadow: 0 1px 5px rgba(0,0,0,.5);transition: .3s;position: relative; } .back{ border: solid #FFF; border-width: 0 3px 3px 0; display: inline-block; padding: 3px;transform: rotate(135deg); -webkit-transform: rotate(135deg);margin-left:10px;cursor:pointer; } .to-right{ margin-left:20px; display: inline-block; padding: 3px;transform: rotate(-45deg); -webkit-transform: rotate(-45deg);cursor:pointer; } .iconSetSave{ font-size:24px;cursor:pointer;margin-right:5px;margin-bottom:4px;color:#FFF; } .zhm_set_page{ z-index:1000000003; position:absolute; top:0px;left:300px; background:#fff; width:300px; height:100%; } .zhm_set_page_header{ border-bottom:1px solid #ccc; height:40px; line-height:40px; display: flex; justify-content: space-between; align-items: center; background-color:#fe6d73; color:#fff; font-size: 15px; } .zhm_set_page_content{ display: flex !important;justify-content: space-between;align-items: center; } .zhm_set_page_list{ margin:0px;padding:0px; } .zhm_set_page_list li{ /*border-bottom:1px solid #ccc;*/ padding:12px 20px; display:block; border-bottom:1px solid #eee; } /*-form-*/ :root { --base-color: #434a56; --white-color-primary: #f7f8f8; --white-color-secondary: #fefefe; --gray-color-primary: #c2c2c2; --gray-color-secondary: #c2c2c2; --gray-color-tertiary: #676f79; --active-color: #227c9d; --valid-color: #c2c2c2; --invalid-color: #f72f47; --invalid-icon: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%20%3Cpath%20d%3D%22M13.41%2012l4.3-4.29a1%201%200%201%200-1.42-1.42L12%2010.59l-4.29-4.3a1%201%200%200%200-1.42%201.42l4.3%204.29-4.3%204.29a1%201%200%200%200%200%201.42%201%201%200%200%200%201.42%200l4.29-4.3%204.29%204.3a1%201%200%200%200%201.42%200%201%201%200%200%200%200-1.42z%22%20fill%3D%22%23f72f47%22%20%2F%3E%3C%2Fsvg%3E"); } .text-input { font-size: 16px; position: relative; right:0px; z-index: 0; } .text-input__body { -webkit-appearance: none; -moz-appearance: none; appearance: none; background-color: transparent; border: 1px solid var(--gray-color-primary); border-radius: 3px; height: 1.7em; line-height: 1.7; overflow: hidden; padding: 2px 1em; text-overflow: ellipsis; transition: background-color 0.3s; width:55%; font-size:14px; } .text-input__body:-ms-input-placeholder { color: var(--gray-color-secondary); } .text-input__body::-moz-placeholder { color: var(--gray-color-secondary); } .text-input__body::placeholder { color: var(--gray-color-secondary); } *, ::after, ::before { box-sizing: initial !important; } .text-input__body[data-is-valid] { padding-right: 1em; } .text-input__body[data-is-valid=true] { border-color: var(--valid-color); } .text-input__body[data-is-valid=false] { border-color: var(--invalid-color); box-shadow: inset 0 0 0 1px var(--invalid-color); } .text-input__body:focus { border-color: var(--active-color); box-shadow: inset 0 0 0 1px var(--active-color); outline: none; } .text-input__body:-webkit-autofill { transition-delay: 9999s; -webkit-transition-property: background-color; transition-property: background-color; } .text-input__validator { background-position: right 0.5em center; background-repeat: no-repeat; background-size: 1.5em; display: inline-block; height: 100%; left: 0; position: absolute; top: 0; width: 100%; z-index: -1; } .text-input__body[data-is-valid=false] + .text-input__validator { background-image: var(--invalid-icon); } .select-box { box-sizing: inherit; font-size: 16px; position: relative; transition: background-color 0.5s ease-out; width:90px; } .select-box::after { border-color: var(--gray-color-secondary) transparent transparent transparent; border-style: solid; border-width: 6px 4px 0; bottom: 0; content: ""; display: inline-block; height: 0; margin: auto 0; pointer-events: none; position: absolute; right: -72px; top: 0; width: 0; z-index: 1; } .select-box__body { box-sizing: inherit; -webkit-appearance: none; -moz-appearance: none; appearance: none; background-color: transparent; border: 1px solid var(--gray-color-primary); border-radius: 3px; cursor: pointer; height: 1.7em; line-height: 1.7; padding-left: 1em; padding-right: calc(1em + 16px); width: 140%; font-size:14px; padding-top:2px; padding-bottom:2px; } .select-box__body[data-is-valid=true] { border-color: var(--valid-color); box-shadow: inset 0 0 0 1px var(--valid-color); } .select-box__body[data-is-valid=false] { border-color: var(--invalid-color); box-shadow: inset 0 0 0 1px var(--invalid-color); } .select-box__body.focus-visible { border-color: var(--active-color); box-shadow: inset 0 0 0 1px var(--active-color); outline: none; } .select-box__body:-webkit-autofill { transition-delay: 9999s; -webkit-transition-property: background-color; transition-property: background-color; } .textarea__body { -webkit-appearance: none; -moz-appearance: none; appearance: none; background-color: transparent; border: 1px solid var(--gray-color-primary); border-radius: 0; box-sizing: border-box; font: inherit; left: 0; letter-spacing: inherit; overflow: hidden; padding: 1em; position: absolute; resize: none; top: 0; transition: background-color 0.5s ease-out; width: 100%; } .textarea__body:only-child { position: relative; resize: vertical; } .textarea__body:focus { border-color: var(--active-color); box-shadow: inset 0 0 0 1px var(--active-color); outline: none; } .textarea__body[data-is-valid=true] { border-color: var(--valid-color); box-shadow: inset 0 0 0 1px var(--valid-color); } .textarea__body[data-is-valid=false] { border-color: var(--invalid-color); box-shadow: inset 0 0 0 1px var(--invalid-color); } .textarea ._dummy-box { border: 1px solid; box-sizing: border-box; min-height: 240px; overflow: hidden; overflow-wrap: break-word; padding: 1em; visibility: hidden; white-space: pre-wrap; word-wrap: break-word; } .toLeftMove{ nimation:moveToLeft 0.5s infinite; -webkit-animation:moveToLeft 0.5s infinite; /*Safari and Chrome*/ animation-iteration-count:1; animation-fill-mode: forwards; } @keyframes moveToLeft{ from {left:200px;} to {left:0px;} } @-webkit-keyframes moveToLeft /*Safari and Chrome*/{ from {left:200px;} to {left:0px;} } .toRightMove{ nimation:moveToRight 2s infinite; -webkit-animation:moveToRight 2s infinite; /*Safari and Chrome*/ animation-iteration-count:1; animation-fill-mode: forwards; } @keyframes moveToRight{ from {left:0px;} to {left:2000px;} } @-webkit-keyframes moveToRight /*Safari and Chrome*/{ from {left:0px;} to {left:200px;} } `; domStyle .appendChild(document.createTextNode(menuSetStyle)); domHead.appendChild(domStyle); var setListJson = [ {'optionName':lang.dyVideoDownload,'optionID':'dyVideoDownload','default':dyVideoDownload}, {'optionName':lang.ksVideoDownload,'optionID':'ksVideoDownload','default':ksVideoDownload}, {'optionName':lang.xiguaVideoDownload,'optionID':'xiguaVideoDownload','default':xiguaVideoDownload}, {'optionName':lang.biliVideoDownload,'optionID':'biliVideoDownload','default':biliVideoDownload}, ]; var setHtml = "
"; setHtml +="
"; setHtml +=""; setHtml +="
"; } setHtml +=""; setHtml +="
"; setHtml +="
"; setHtml +="'; setHtml +='
'; setHtml += ""; if(document.querySelector('#setMask')) return; this.createElement('div','zhmMenu'); let zhmMenu = document.getElementById('zhmMenu'); zhmMenu.innerHTML = setHtml; let timerZhmIcon = setInterval(function(){ if (document.querySelector('#zhmMenu')){ clearInterval(timerZhmIcon); // 取消定时器 let circular = document.querySelectorAll('.circular'); circular.forEach(function(item){ item.addEventListener('click', function(e){ let buttonStyle = item.children[0].style; let left = buttonStyle.left; left = parseInt(left); let listLeftValue; if(left==0){ buttonStyle.left = '22px'; buttonStyle.background = '#fe6d73'; item.style.background='#ffE5E5'; if(item.nextSibling && item.nextSibling.getAttribute('data')){ item.nextSibling.setAttribute('style','border: solid #ccc;border-width: 0 3px 3px 0;') } listLeftValue = 22; }else{ buttonStyle.left = '0px'; buttonStyle.background = '#fff'; item.style.background='#fff'; if(item.nextSibling){ item.nextSibling.setAttribute('style','border: solid #EEE;border-width: 0 3px 3px 0;') } listLeftValue = 0; } let setListID = item.id; GM_setValue(setListID,listLeftValue); }) }); document.querySelector('.iconSetSave').addEventListener('click',()=>{ location.href=location.href; }) } }) } createElement(dom,domId){ var rootElement = document.body; var newElement = document.createElement(dom); newElement.id = domId; var newElementHtmlContent = document.createTextNode(''); rootElement.appendChild(newElement); newElement.appendChild(newElementHtmlContent); } request(method,url,data,isCookie=''){ let request = new XMLHttpRequest(); return new Promise((resolve,reject)=>{ request.onreadystatechange=function(){ if(request.readyState==4){ if(request.status==200){ resolve(request.responseText); }else{ reject(request.status); } } } request.open(method,url); //request.withCredentials = true; if(isCookie){ request.withCredentials = true; } request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); request.send(data); }) } setCookie(cname,cvalue,exdays){ var d = new Date(); d.setTime(d.getTime()+(exdays*24*60*60*1000)); var expires = "expires="+d.toGMTString(); document.cookie = cname+"="+cvalue+"; "+expires; } getCookie(cname){ var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i{obj[$1]=$2}); return obj; } static getElement(css,all=''){ return new Promise((resolve,reject)=>{ let num = 0; let timer = setInterval(function(){ num++ let dom; if(all == false){ dom = document.querySelector(css); if(dom){ clearInterval(timer); resolve(dom); } }else{ dom = document.querySelectorAll(css); if(dom.length>0){ clearInterval(timer); resolve(dom); } } if(num==20){ clearInterval(timer); resolve(false); } },300) }) } static toast(msg,duration){ duration=isNaN(duration)?3000:duration; let toastDom = document.createElement('div'); toastDom.innerHTML = msg; //toastDom.style.cssText="width: 60%;min-width: 150px;opacity: 0.7;height: 30px;color: rgb(255, 255, 255);line-height: 30px;text-align: center;border-radius: 5px;position: fixed;top: 40%;left: 20%;z-index: 999999;background: rgb(0, 0, 0);font-size: 12px;"; toastDom.style.cssText='padding:2px 15px;min-height: 36px;line-height: 36px;text-align: center;transform: translate(-50%);border-radius: 4px;color: rgb(255, 255, 255);position: fixed;top: 50%;left: 50%;z-index: 9999999;background: rgb(0, 0, 0);font-size: 16px;' document.body.appendChild(toastDom); setTimeout(function() { var d = 0.5; toastDom.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in'; toastDom.style.opacity = '0'; setTimeout(function() { document.body.removeChild(toastDom) }, d * 1000); }, duration); } //create zhmLogoIcon zhmLogo(){ var _this = this; let sortDiv = iconVipPosition=='left'?'row':'row-reverse'; let playVideoStyle = ` .zhm_play_vidoe_icon{ padding-top:2px; cursor:pointer; z-index:999999; position:fixed;${iconVipPosition}:5px;top:${iconVipTop}px; text-align:center; overflow:visible; display:flex; flex-direction:${sortDiv}; width:auto; } .zhm_play_video_wrap{ z-index:9999999; overflow: hidden; width:300px; } .iconLogo{ opacity:${iconVipOpacity/100}; } .zhm_play_video_line{ width:320px; height:316px; overflow-y:scroll; overflow-x:hidden; } .zhm_play_vide_line_ul{ width:300px; display: flex; justify-content: flex-start; flex-flow: row wrap; list-style: none; padding:0px; margin:0px; } .zhm_play_video_line_ul_li{ padding:4px 0px; margin:2px; width:30%; color:#FFF; text-align:center; background-color:#f24443; box-shadow:0px 0px 10px #fff; font-size:14px; } .zhm_play_video_line_ul_li:hover{ color:#260033; background-color:#fcc0c0 } .zhm_line_selected{ color:#260033; background-color:#fcc0c0 } .zhm_play_video_jx{ width:100%; height:100%; z-index:999999; position: absolute;top:0px;padding:0px; } `; domStyle .appendChild(document.createTextNode(playVideoStyle)); domHead.appendChild(domStyle); let playWrapHtml = ""; let zhmPlay = document.getElementById('zhmlogo'); let playLineDom = document.createElement('div'); playLineDom.className = 'playLineDiv zhm_play_video_wrap'; playLineDom.style.display = 'none'; playLineDom.innerHTML = playWrapHtml; zhmPlay.appendChild(playLineDom); let playLineTd = document.querySelectorAll('.playLineTd'); playLineTd.forEach(function(item){ item.addEventListener('click',function(){ window.open(item.getAttribute('url')+location.href); }) }) document.querySelector('.playButton').onmouseover=()=>{ document.querySelector(".playLineDiv").style.display='block'; } document.querySelector('.playButton').onmouseout=()=>{ document.querySelector(".playLineDiv").style.display='none'; } _this.zhmLogoDrag('youtube',''); }else{ let zhmIcon = document.querySelector('#zhmIcon'); if(zhmIcon){ zhmIcon.parentNode.removeChild(zhmIcon); } let zhmlogo = document.querySelector('#zhmlogo'); if(zhmlogo){ //zhmlogo.parentNode.removeChild(zhmlogo); zhmlogo.style.opacity=0; } } },500) } } var nowWeb = []; for(let i=0;i