您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
打开视频自动点赞
当前为
// ==UserScript== // @name Bilibili - 不再白嫖 // @namespace top.qwq123.scripts.BilibiliAutoLike // @version 0.2 // @description 打开视频自动点赞 // @author XcantloadX // @run-at document-end // @icon https://static.hdslb.com/images/favicon.ico // @match *://www.bilibili.com/video/* // @match *://t.bilibili.com // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js // @license MIT License // ==/UserScript== (function() { const AutoLike = { settings: { enableVideoPage: true, //是否启用视频自动点赞(true=启用,false=禁用,下同) enableFollowingPage: false //是否启用动态自动点赞 }, init: function(){ if(this.settings.enableFollowingPage && window.location.host === "t.bilibili.com"){ this.initFollowing(); } else if(this.settings.enableVideoPage && window.location.host === "bilibili" && window.location.pathname.indexOf("video") > 0){ $(this.initVideo); } }, //动态页面 initFollowing: function(){ let likes = []; //待点赞按钮 let observer = new MutationObserver(function(changes){ changes.forEach(function(change){ if(change.type != "childList") return; if($(change.target).hasClass("card")){ //判断是否是动态卡片 let likeBtn = $(change.target).find(".button-bar").find(".custom-like-icon")[0]; if(typeof(likeBtn) == "undefined" || $(likeBtn).hasClass("zan-hover")) //未找到按钮或已赞 return; if(!likes.includes(likeBtn)) //避免重复添加 likes.push(likeBtn); } }); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.setInterval(function(){ if(likes.length > 0){ $(likes.shift()).click(); console.log("已赞"); } }, 1000); //为了避免太快,采用队列的方式逐个点赞 }, //视频页面 initVideo: function(){ let liked = false; let oldPath = ""; //刷新检测 window.setInterval(function(){ if(location.pathname != oldPath){ oldPath = location.pathname; window.setTimeout(doLike, 5000); } }); function doLike(){ let like = undefined; if($(".ops .like").length > 0) like = $(".ops .like"); else return; if(!$(like).hasClass("on")){ $(like).click(); $(like).addClass("on"); //防止太卡 liked = true; } } } }; AutoLike.init(); })();