// ==UserScript== // @name 抖音时间控制 // @description 自用抖音时间管理+其他优化(想要实现但未实现:下载视频:替换广告(已实现):替换超过5分钟的视频:5分钟后视频上遮罩(感觉没必要了),一个小数只能刷2次:替换直播 // @namespace http://tampermonkey.net/ // @version 2023.3.9 // @author 仰晨 // @match *://*.douyin.com/* // @icon https://lf1-cdn-tos.bytegoofy.com/goofy/ies/douyin_web/public/favicon.ico // @grant none // @license AGPL License // @downloadURL none // ==/UserScript== var min5 = false; //监听 鼠标滚轮滚动2023.3.9 // 选取要观察的节点 var targetNode = document; // 监听鼠标滚轮事件 targetNode.addEventListener('wheel', function(event) { if(min5){alert('5分钟到啦');} setTimeout(function (){ let fuClass=document.getElementsByClassName("zK9etl_2 slider-video"); if(fuClass.length>2){ let Advertising = fuClass[2].getElementsByClassName("RA5iG98_");//广告 if(Advertising.length>0){ //alert('下一个是广告'); replacVideo(); } } },2000) }); //替换视频 function replacVideo() { let videos = document.getElementsByTagName("video"); let index=videos.length != 1 ? 2 : 0; if(index>1){ let video = videos[index]; // 判断是否存在src属性 if (!video.hasAttribute("src")){ video.src = '//www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cg2650rc77u1uog8eaig&line=0&file_id=ea45ae18d426468187776aaacaed6f30&sign=6cdbe8be7c6a55eb9a95a38bc7194185&'; // 设置视频URL video.load(); // 加载视频 //如果视频出现直播的话会没有这些标签.所以《视频标签》==《正常视频父类标签》是就是没有出现直播 就执行2023.3.9 let fuClass=document.getElementsByClassName("zK9etl_2 slider-video"); if(index+1==fuClass.length){ let fu=fuClass[index]; //隐藏弹幕(失败了:因为不会提前加载只会滚动到视频的时候才出现,点击下方的关闭样式又会影响到其他的,现在想法就到五分钟直接吧弹幕的样式none)2023.3.8 [class="I6WvmKj6 E8wnDxIb danmu"] //隐藏左边的点赞那栏2023.3.8 fu.getElementsByClassName("L1TH4HdO positionBox")[0].style.display = "none"; //隐藏名字和描述2023.3.8 fu.getElementsByClassName("tSXOCvQc")[0].style.display = "none"; //替换评论区 replacComment(index); } } } } //替换评论区2023.3.7 function replacComment(index) { let Comment=document.getElementsByClassName("aDQw7OWI _628BWQES LookModalFrameFast")[index]; // 包涵集合的评论区得隐藏 Comment.getElementsByClassName("nNXxvS1t")[0].style.display = "none"; Comment.innerHTML="ikun"; let styles=`font-size: 91px; color: white; justify-content: center; /* 水平居中 */ align-items: center; /* 垂直居中 */ ` Comment.style=styles; } //进入的是刷视频页才执行↓↓↓ if (location.href === "https://www.douyin.com/"){ //加载完成时自行↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ window.onload=function (){ //1.5秒后自动打开评论区 setTimeout(function (){document.getElementsByClassName("tzVl3l7w")[0].click();},1500) //抖音最近默认进来是静音的,直接解除静音(muted) document.getElementsByTagName("video")[0].muted = false; //加载完成时自行-↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ } var 延迟时间=1*60*1000; //开始计时=============================================================================================== setTimeout(function (){ //赋初始值 var i = 1; var sj="00:00" var videoTime=document.getElementsByClassName('time-current'); var index=0;//如果只刷一个视频就只有一个索引,开始第二个的时候就会出现三个索引【0,1,2】当前一般是【1】 min5 = true; var div = document.createElement("div"); div.innerText="5分钟到了-----------------------------------------------------"; div.setAttribute('id','kun'); //设置标签属性 var fu = document.getElementById("slidelist");//找到想成为的父标签 var one=fu.firstChild;// 获取父标签的第一个子元素 fu.insertBefore(div,one); // 在父标签的第一个子元素,前插入div标签 //改一下样式 { let style=` ul.JTui1eE0{ transition: all 20s ; width: 100px; background-color: #5f6175a8; border-radius: 8px; margin: 0px 10px; box-shadow: 0 0px 9px 1px #fff; /*阴影 水平偏移 垂直偏移 模糊 阴影大小*/ } #kun{ width:100%; height: 100%; animation:ikun 5s infinite; } @keyframes ikun { 0% {background-color: red;} 50% {background-color: #06f;} 100% {background-color: red;} } [class="xgplayer-playswitch recommend-out-switch-btn IvL3R0Q4"], /*隐藏右边点击上下看视频按钮*/ [class="I6WvmKj6 E8wnDxIb danmu"] /*隐藏弹幕*/ { display: none !important; } `; let ele=document.createElement("style"); ele.innerHTML=style; document.getElementsByTagName('head')[0].appendChild(ele); } //判断退出代码↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ for (let i=0; i<3600; i++)task(i); function task(i) {setTimeout( function () { try{ if (videoTime.length===3){ index=1; //获取视频个数 要么是1个要么是3个 三个的时候 当前看的是第二个 // 到时间了 替换视频 replacVideo(); } //判断这一秒的时间是否大过上一秒的时间 大过说明看完了 该润了 if(sj>videoTime[index].innerText){ alert("够钟死心了"); window.opener = null; window.open('', '_self'); window.close(); //这种情况是偶尔才会出现,没有自动关闭,就让声音隐藏 setTimeout(function (){ document.getElementsByTagName("video")[0].muted = true; },1000) } //刷新时间值 sj=videoTime[index].innerText; document.getElementsByClassName("time")[index].innerHTML = "---------5分钟到了+"+i+"秒"+sj+">?"+videoTime[index].innerText;i++; }catch(err){ console.log("离谱"); } }, 1000 * i);} },延迟时间);//在5分钟后执行代码-------------------------------------------------------------------------------------------------------- }//进入的是刷视频页才执行↑↑↑↑ /*个人主页生效-----------------------------*/ else if(location.href.startsWith("https://www.douyin.com/user")){ //添加一个到刷视频的按钮 const parent = document.querySelector("#root"); const newLink = document.createElement("a"); newLink.setAttribute("href", "https://www.douyin.com/"); newLink.setAttribute("id", "ikun"); newLink.setAttribute("title", "到刷视频页面"); parent.appendChild(newLink); } //样式-|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|-|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|- { let css = ""; /*整个抖音域名都生效*/ if ((location.hostname === "douyin.com" || location.hostname.endsWith(".douyin.com"))) { css += ` #douyin-sidebar /*右下角的意见反馈*/ { display: none; } .N_HNXA04.KYtgzo9m{ /*抖音大大的左边栏*/ transition: all 0.5s ; /*过渡效果2023.1.31*/ max-width: 10px; } .HQwsRJFy, /*左上 抖音 logo */ [data-e2e="douyin-navigation"]{ /*抖音的左边栏内容*/ display: none; } /*移动到左边就弹出来*/ .N_HNXA04.KYtgzo9m:hover .HQwsRJFy, .N_HNXA04.KYtgzo9m:hover [data-e2e="douyin-navigation"], .N_HNXA04.KYtgzo9m:hover{ max-width:172px; display: block; } `; } /*个人主页生效-----------------------------*/ if (location.href.startsWith("https://www.douyin.com/user")) { css += ` .MFb3tP0s._bpGHYWu > :nth-child(-n+3), /*前3个直接子元素 1、客户端 2、收藏网页 3、合作*/ [class="feXqXaSk a3sjxRqS"], /*收藏夹|视频|合集*/ [class="N_HNXA04 KYtgzo9m"], /*抖音大大的左边栏-*/ [class="iwzpXgQ3 lXuWkeYW dSNgkU25 K4TZD9ct wJgU15d1"], /*滚动还显示搜索栏*/ [class="gX8AKvzT gthle0Gj"], /*滚动还显示作品栏*/ [class="_7gdyuNUv"] /*主页的下载电脑客户端*/ { display: none !important; /*使用!important可以覆盖所有其他样式规则,但不建议过度使用*/ } /*背景全黑----------------------------------*/ .feXqXaSk, /*收藏夹|视频|合集*/ [class="gX8AKvzT"], /*作品栏*/ [class="UKp0VfC1"], /*下面的视频背景*/ html[dark] ._LDrC7Wb.Smb5gBZJ:before{ /*名片*/ background-image: linear-gradient(to bottom, #000, #000); } /*使用!important可以覆盖所有其他样式规则,但不建议过度使用。例如: .N_HNXA04 { background-color: red !important; } 但是,使用!important可能会导致样式难以维护和调试,因此应该尽量避免使用它。*/ /*生成的到刷视频按钮的样式*/ #ikun { z-index: 999; position: absolute; top: 5px; left: 5px; width: 39px; height: 39px; border-radius: 50%; text-align: center; line-height: 30px; background-color: #4a4949; box-shadow: 0 0 5px #999; cursor:pointer; background-image: url(https://www.douyin.com/favicon.ico); background-repeat: no-repeat; background-size: 100%; } `; } /*刷视频 搜索视频 页面生效 */ if (location.href === "https://www.douyin.com/" || location.href.startsWith("https://www.douyin.com/search/")) { css += ` /*评论区广告提交表单*/ .htirveP0:before{ display: flex; min-width: 60px; min-height: 680px; color: #929faf; content: "ikun:广告已被覆盖"; justify-content: center; /* 水平居中 */ align-items: center; /* 垂直居中 */ font-size: 40px; } [class="XNmfpct4 fJOjbqAw"], /*直播间名字 标题*/ [class="NWMyy49m"], /*点击进入直播间*/ [class="U6kxNmZU"], /*直播叫你买浮窗*/ [class="QUUswvJ3"], /*客户端*/ [class="N_HNXA04 WcK6IrkT JVPLvXh3"], /*搜索页生效--抖音大大的左边栏*/ [class="JTui1eE0"]:nth-child(2), /*收藏网页*/ [class="JTui1eE0"]:nth-child(3) { /*合作*/ display: none !important; } `; } if (typeof GM_addStyle !== "undefined") { GM_addStyle(css); } else { let styleNode = document.createElement("style"); styleNode.appendChild(document.createTextNode(css)); (document.querySelector("head") || document.documentElement).appendChild(styleNode); } } //样式结束-|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|-