Greasy Fork is available in English.
自用抖音时间管理+其他优化(md白干了好久 这个差不多是最最终正常版了(最多还有2个版本),如果后面还有版本 一定管理的很变态)
当前为
// ==UserScript==
// @name 抖音时间控制
// @description 自用抖音时间管理+其他优化(md白干了好久 这个差不多是最最终正常版了(最多还有2个版本),如果后面还有版本 一定管理的很变态)
// @namespace http://tampermonkey.net/
// @version 2023.3.6-7
// @author 仰晨
// @match *://*.douyin.com/*
// @icon https://lf1-cdn-tos.bytegoofy.com/goofy/ies/douyin_web/public/favicon.ico
// @grant none
// @license AGPL License
// ==/UserScript==
//替换视频
function replacVideo() {
// //拿到最后一个视频的索引
// let videos=document.getElementsByClassName("xg-video-container");
// let index=videos.length-1;
// if (videos[index].getAttribute('ikun')!="ikun"){
// let str=`
// <video class="" ikun="ikun" playsinline="true" x5-playsinline="true" webkit-playsinline="true" tabindex="2" mediatype="video" crossorigin="anonymous" data-xgplayerid="35b3c8b0-2c21-4fef-9e38-b3d123526127">
// <source class="" src="//v26-web.douyinvod.com/a69b35bc3ecba305d628496cd7a459c0/6405f480/video/tos/cn/tos-cn-ve-15c001-alinc2/ogCKhAAfHI0BceQg9aAAKFUjVlYBztKBCsLyiE/?a=6383&ch=26&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&br=1735&bt=1735&cs=0&ds=3&ft=bvTKJbQQqUYqfJEZPo0OW_EklpPiX~KTvMVJEunzR2vPD-I&mime_type=video_mp4&qs=0&rc=M2lnZGRkOjo0OTk3O2g4ZEBpamQ7cjQ6ZjM5ajMzNGkzM0AwM2JgXjM0NTUxL2EuXjFiYSNmYmRycjRvMi9gLS1kLS9zcw%3D%3D&l=2023030621102185BEB1EDBC405F12AFF9&btag=20000" type="">
// <source class="" src="//v3-web.douyinvod.com/ca92bed2ed74ca560bdf759400285ac7/6405f480/video/tos/cn/tos-cn-ve-15c001-alinc2/ogCKhAAfHI0BceQg9aAAKFUjVlYBztKBCsLyiE/?a=6383&" type="">
// <source class="" src="//www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cg2650rc77u1uog8eaig&line=0&file_id=ea45ae18d426468187776aaacaed6f30&sign=6cdbe8be7c6a55eb9a95a38bc7194185&" type="">
// </video>`
// var div = document.createElement('div');
// div.innerHTML = str;
// videos[index].innerHTML="ikun";
// //删除原来视频
// let childNodes =videos[index].getElementsByTagName("*");
// while (childNodes.length > 0) {
// videos[index].removeChild(childNodes[0]);
// }
// let video = document.getElementsByTagName("video")[index];
// videos[index].getElementsByTagName("source")[0].setAttribute("src", "//www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cg2650rc77u1uog8eaig&");
// videos[index].getElementsByTagName("source")[1].setAttribute("src", "//www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cg2650rc77u1uog8eaig&");
// videos[index].getElementsByTagName("source")[2].setAttribute("src", "//www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cg2650rc77u1uog8eaig&");
// video.load(); // 重新加载视频以清空缓冲
// videos[index].appendChild(div.children[0]);
// video.load(); // 重新加载视频以清空缓冲
// video.volume = 0.20; //视频音量为20
// // 定义一个变量用于跟踪是否正在播放
// let isPlaying = false;
// video.addEventListener('click',() => {
// if (!isPlaying) {
// // 如果视频尚未播放,则开始播放
// video.play();
// isPlaying = true;
// }
// else {
// // 如果视频正在播放,则暂停播放
// video.pause();
// isPlaying = false;
// }});
// }
let videos = document.getElementsByTagName("video");
let index=videos.length-1;
let video = videos[index];
video.src = '//www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cg2650rc77u1uog8eaig&line=0&file_id=ea45ae18d426468187776aaacaed6f30&sign=6cdbe8be7c6a55eb9a95a38bc7194185&'; // 设置视频URL
video.load(); // 加载视频
}
//进入的是刷视频页才执行↓↓↓
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 延迟时间=5*60*1000;
//开始计时===============================================================================================
setTimeout(function (){
//赋初始值
var i = 1;
var sj="00:00"
var videoTime=document.getElementsByClassName('time-current');
var index=0;//如果只刷一个视频就只有一个索引,开始第二个的时候就会出现三个索引【0,1,2】当前一般是【1】
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标签
//改一下样式
do{
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;}
}
`;
let ele=document.createElement("style");
ele.innerHTML=style;
document.getElementsByTagName('head')[0].appendChild(ele);
}while(false);
//判断退出代码↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
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分钟后执行代码--------------------------------------------------------------------------------------------------------
}//进入的是刷视频页才执行↑↑↑↑
//样式-|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|-|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|-
{
let css = "";
/*整个抖音域名都生效*/
if ((location.hostname === "douyin.com" || location.hostname.endsWith(".douyin.com"))) {
css += `
#douyin-sidebar, /*右下角的意见反馈*/
.QUUswvJ3 /*客户端推荐*/
{
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 += `
[class="N_HNXA04 KYtgzo9m"], /*抖音大大的左边栏-*/
[class="iwzpXgQ3 lXuWkeYW dSNgkU25 K4TZD9ct wJgU15d1"], /*滚动还显示搜索栏*/
[class="gX8AKvzT gthle0Gj"], /*滚动还显示作品栏*/
[class="_7gdyuNUv"], /*主页的下载电脑客户端*/
[class="JTui1eE0"]:nth-child(3), /*收藏网页*/
[class="JTui1eE0"]:nth-child(4) { /*合作*/
display: none !important; /*使用!important可以覆盖所有其他样式规则,但不建议过度使用*/
}
/*背景全黑----------------------------------*/
[class="gX8AKvzT"], /*作品栏*/
[class="UKp0VfC1"], /*下面的视频背景*/
html[dark] ._LDrC7Wb.Smb5gBZJ:before{ /*名片*/
background-image: linear-gradient(to bottom, #000, #000);
}
/*使用!important:使用!important可以覆盖所有其他样式规则,但不建议过度使用。例如:
.N_HNXA04 {
background-color: red !important;
}
但是,使用!important可能会导致样式难以维护和调试,因此应该尽量避免使用它。*/
`;
}
/*刷视频 搜索视频 页面生效 */
if (location.href === "https://www.douyin.com/" || location.href.startsWith("https://www.douyin.com/search/")) {
css += `
[class="N_HNXA04 WcK6IrkT JVPLvXh3"], /*搜索页生效--抖音大大的左边栏*/
[class="JTui1eE0"]:nth-child(2), /*收藏网页*/
[class="JTui1eE0"]:nth-child(3) { /*合作*/
display: none;
}
`;
}
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);
}
}
//样式结束-|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|-