您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
acfun直播点赞插件
当前为
// ==UserScript== // @name Acfun Live Like Extension // @namespace https://github.com/aoi-umi // @version 0.1 // @description acfun直播点赞插件 // @author aoi-umi // @match *://live.acfun.cn/* // @grant none // ==/UserScript== (function () { function AcLikeExt() { let prefix = 'ext-ac-like-'; let acceptBtnName = `${prefix}accept`; let cancelBtnName = `${prefix}cancel`; let timeInputName = `${prefix}time`; let dialogName = `${prefix}dialog`; let head = document.querySelector('head'); let body = document.querySelector('body'); let defaultTime = 100; let likeBtn = document.querySelector('.like-heart'); let toggle = this.toggle = function (dom, show) { if (show === undefined) show = !(dom.style.display !== 'none') dom.style.display = !show ? 'none' : '' }; // 样式 let initStyle = () => { let style = document.createElement('style'); style.innerHTML = ` .${prefix}menu { background: white; position: fixed; top: 100px; right: 10px; border-radius: 50%; border: 1px solid #dcdee2; width: 40px; height: 40px; z-index: 1000; cursor: pointer; display: flex; justify-content: center; align-items: center; } .${prefix}dialog-box { position: fixed; top: 100px; right: 10px; display: flex; justify-content: center; z-index: 1000; } .${prefix}dialog { background: white; width: 250px; height:100px; border: 1px solid #dcdee2; border-radius: 5px; padding: 10px; } .${prefix}dialog > * { margin-bottom: 5px; } .${prefix}input { background-color: #f8f8f8 !important; color: #333; border-radius: 5px; padding: 2px 10px; font-size: 14px; font-weight: 400; text-align: left; line-height: 20px; border: 0; } .${prefix}btn { box-sizing: border-box; height: 28px; border-radius: 4px; padding: 3px 10px; font-size: 14px; line-height: 14px; cursor: pointer; position: relative; display: inline-flex; align-items: center; font-weight: 400; white-space: nowrap; text-align: center; background-image: none; background-color: #fff; border: 1px solid #e5e5e5; color: #999; } .${prefix}btn-primary { background: #fd4c5d; color: #fff; } `; head.appendChild(style); }; let initView = () => { addMenu(); addDialog(); }; let addMenu = () => { let dom = document.createElement('div'); dom.classList = [ `${prefix}menu` ]; dom.innerHTML = ` <svg width="20" viewBox="0 0 70 60"> <path d="M0 10 L10 10 L10 0 L30 0 L30 10 L40 10 L40 0 L60 0 L60 10 L70 10 L70 30 L60 30 L60 40 L50 40 L50 50 L40 50 L40 60 L30 60 L30 50 L20 50 L20 40 L10 40 L10 30 L0 30 Z" fill="red" fill-rule="evenodd" /> </svg> `; dom.addEventListener('click', function () { acLikeExt.run() }) body.appendChild(dom) }; let addDialog = () => { let dialogHtml = ` <div class="${prefix}dialog"> <div>时间(毫秒/次, 大于等于100的数)</div> <div> <input class="${prefix}input" id="${timeInputName}" value=${defaultTime} autocomplete="off" type="text" /> </div> <div> <button id="${cancelBtnName}" type="button" class="${prefix}btn">取消</button> <button id="${acceptBtnName}" type="button" class="${prefix}btn ${prefix}btn-primary" >确定</button> </div> </div>`; dialog = document.createElement("div"); dialog.id = dialogName dialog.classList = [ `${prefix}dialog-box` ]; dialog.innerHTML = dialogHtml; toggle(dialog, false); let acceptBtn = dialog.querySelector(`#${acceptBtnName}`) acceptBtn.addEventListener('click', function () { acceptClick(); }); let cancelBtn = dialog.querySelector(`#${cancelBtnName}`) cancelBtn.addEventListener('click', function () { toggle(dialog); }); body.appendChild(dialog); acLikeExt.dialog = dialog }; let acceptClick = function () { let dialog = acLikeExt.dialog; let time = dialog.querySelector(`#${timeInputName}`).value; time = new Number(time); if (isNaN(time) || time < 100) { return alert('请输入正确的时间') } toggle(dialog); toggleLike(time); }; let toggleLike = function (time) { if (!likeBtn) return alert('当前页面不支持'); if (acLikeExt.acLike) { console.log('停止点赞') clearInterval(acLikeExt.acLike); acLikeExt.acLike = 0; } else { console.log('开始点赞') acLikeExt.acLike = setInterval(function () { likeBtn.click(); }, time); } }; this.init = function () { if (acLikeExt.inited) return; initStyle(); initView(); this.inited = true; }; this.run = function () { // 运行中,停止 if (acLikeExt.acLike) { toggleLike() } else { let dialog = acLikeExt.dialog; toggle(dialog, true); } }; } let acLikeExt = window.extAcLike; if (!acLikeExt) acLikeExt = window.extAcLike = new AcLikeExt(); acLikeExt.init(); })()