哔哩哔哩视频、番剧自动点赞
發現了一些bug(2分鐘後不管是不是同一個視頻都點讚了),修正了,新代碼從代碼開始直接覆蓋到點讚上面就好,
(function () { 'use strict'; var originUrl = ""; var interval = setInterval(function () { judgeUrl() }, 10000); var currentUrl = ""; // 監測url變化 function judgeUrl() { currentUrl = document.location.toString(); if (originUrl != currentUrl) { originUrl = currentUrl clearInterval(interval); countTwoMins(); } } // 計時兩分鐘 async function countTwoMins(){ let i; for (i = 0; i < 12; i++){ await new Promise(resolve => setTimeout(resolve, 10000)); currentUrl = document.location.toString(); if (originUrl != currentUrl) { break; } } if (i == 12){ clickLike() } interval = setInterval(function () { judgeUrl() }, 10000); }
新版本已添加延迟点赞的功能并重新优化了系统逻辑,感谢使用
作者您好,我又有個小提議,添加觀看百分比而不是時間,因為有些視頻例如自創的歌曲,就算整首歌聽完可能時間不足2分鐘,而有些影片可能30分鐘,但我看了一開始的3分鐘就覺得無趣不想看了,這種情況我希望能夠點讚歌曲但同時不會點讚影片
// 計觀看百分比
async function countpercentage(){
//少於30秒的視頻不自動點讚
if(player.getDuration() > 30){
const target = 80; //百分比
//console.log("target: ",target,"%")
while (true) {
await new Promise(resolve => setTimeout(resolve, 5000));
if (originUrl != currentUrl) {
//console.log("改左Url了");
break;
}
const watched = player.getCurrentTime() / player.getDuration()
//console.log("watched: ",watched)
const watchedTarget = target/100
//.log("watchedTarget: ",watchedTarget)
currentUrl = document.location.toString();
if (watched > watchedTarget) {
clickLike()
break;
}
}
}
interval = setInterval(function () { judgeUrl() }, 5000);
}
這是我之前寫的,可以正常運作
自己添加了2分鐘後才點讚,其他一切不變,例如還是10秒檢查一次網址有沒有變化,方便大家覺得沒有幫助或者不有趣的視頻不需要取消點讚。
只需要把 judgeUrl 整個換掉就好。
如果覺得2分鐘太長,可以把120000改成自己覺得合適的時間,這是毫秒,120000 = 2分鐘。