Greasy Fork is available in English.
这是一个基于抖音直播的自动点赞脚本,支持调节点赞频率,修改自别人的脚本
当前为
// ==UserScript==
// @name 抖音网页直播点赞(可调节频率,可设置是否默认自动点赞)
// @namespace http://tampermonkey.net/
// @version 2.0
// @description 这是一个基于抖音直播的自动点赞脚本,支持调节点赞频率,修改自别人的脚本
// @author 余某人
// @match *://live.douyin.com/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
let page = document.getElementsByTagName('body')[0];
// 首先添加全局样式
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
// 添加所有需要的样式
addGlobalStyle(`
.kolento {
content: '';
font-size: 14px;
position: fixed;
top: 70px;right: 30px;
z-index: 500;
cursor: pointer;
background: linear-gradient(90deg,#f4c8c7 0,#0c61bb 45%,#0c61bb 55%,#fcc6c6)!important;
border-radius: 50%;
color: #fff;
display: block;
width: 46px;height: 46px;
line-height: 16px;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
transition: all ease 0.3s;
}
.kolento:hover {
background-color: #4abf8a;
transform: rotate(360deg)
}
.total {
font-size: 14px;
position: fixed;
top: 79px;
right: 85px;
z-index: 500;
background: linear-gradient(90deg,#f4c8c7 0,#0c61bb 45%,#0c61bb 55%,#fcc6c6)!important;
color: #fff;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
transition: all ease 0.3s;
padding: 5px 8px;
border-radius: 20px;
}
.total p {
color:#fff;
}
.freq-adjuster {
position: fixed;
top: 130px;
right: 30px;
z-index: 500;
background: linear-gradient(90deg,#f4c8c7 0,#0c61bb 45%,#0c61bb 55%,#fcc6c6)!important;
color: #fff;
padding: 8px;
border-radius: 20px;
display: flex;
flex-direction: column;
gap: 8px;
}
.freq-adjuster > div {
display: flex;
align-items: center;
gap: 5px;
}
.freq-input {
width: 100px;
border: none;
border-radius: 10px;
padding: 2px 5px;
text-align: center;
font-size: 14px;
}
.freq-label {
font-size: 12px;
white-space: nowrap;
}
.auto-like-option {
display: flex;
align-items: center;
gap: 5px;
font-size: 12px;
cursor: pointer;
}
.auto-like-checkbox {
cursor: pointer;
}
`);
// 然后创建并添加所有元素
let kolento = document.createElement("p");
kolento.className="kolento";
kolento.innerHTML='开始<br/>点赞'
page.append(kolento);
let total = document.createElement("div");
total.className="total";
total.innerHTML='<p class="text">点击数:</p ><p class="kolento-all">0</p >';
page.append(total);
let freqAdjuster = document.createElement("div");
freqAdjuster.className="freq-adjuster";
freqAdjuster.innerHTML=`
<div>
<span class="freq-label">点赞频率(ms):</span>
<input type="number" class="freq-input" value="100" min="1" max="500">
</div>
<label class="auto-like-option">
<input type="checkbox" class="auto-like-checkbox">
<span>默认自动点赞</span>
</label>
`;
freqAdjuster.style.display = 'none';
page.append(freqAdjuster);
var timeBox;
let totalNum = 0;
let likeFrequency = 100; // 从50改为100
let num = document.getElementsByClassName('kolento-all')[0];
console.log('num',num);
num.innerHTML=totalNum;
let target = document.getElementsByClassName('LO5TGkc0')
// 简化hover事件监听
kolento.addEventListener('mouseenter', function() {
freqAdjuster.style.display = 'flex';
});
kolento.addEventListener('mouseleave', function(e) {
setTimeout(() => {
if (!freqAdjuster.matches(':hover')) {
freqAdjuster.style.display = 'none';
}
}, 100);
});
freqAdjuster.addEventListener('mouseenter', function() {
freqAdjuster.style.display = 'flex';
});
freqAdjuster.addEventListener('mouseleave', function() {
freqAdjuster.style.display = 'none';
});
// 修改频率更新监听
document.querySelector('.freq-input').addEventListener('change', function(e) {
let value = parseInt(e.target.value);
if (value <= 0) {
value = 100;
this.value = 100;
} else if (value > 120000) {
value = 120000;
this.value = 120000;
}
likeFrequency = value;
// 只有在当前正在点赞的状态下才重新设置定时器
if (timeBox && kolento.innerHTML.indexOf('停止') > -1) {
clearInterval(timeBox);
timeBox = setInterval(() => {
totalNum++;
num.innerHTML=totalNum;
target[0].click();
}, likeFrequency);
}
});
kolento.onclick=function(){
if(kolento.innerHTML.indexOf('开始')>-1){
console.log('执行点赞脚本')
kolento.innerHTML='停止<br/>点赞'
timeBox = setInterval(()=>{
totalNum++;
num.innerHTML=totalNum;
target[0].click();
}, likeFrequency);
}else{
console.log('停止点赞');
clearInterval(timeBox);
kolento.innerHTML='开始<br/>点赞'
}
}
// 获取复选框元素
const autoLikeCheckbox = document.querySelector('.auto-like-checkbox');
// 从localStorage获取设置,如果没有则默认为true
const autoLikeEnabled = localStorage.getItem('autoLikeEnabled');
const shouldAutoLike = autoLikeEnabled === null ? false : autoLikeEnabled === 'true';
// 设置复选框初始状态
autoLikeCheckbox.checked = shouldAutoLike;
// 如果启用了自动点赞,自动开始点赞
if (shouldAutoLike) {
kolento.innerHTML = '停止<br/>点赞';
timeBox = setInterval(() => {
totalNum++;
num.innerHTML = totalNum;
target[0].click();
}, likeFrequency);
}
// 监听复选框变化
autoLikeCheckbox.addEventListener('change', function(e) {
localStorage.setItem('autoLikeEnabled', e.target.checked);
});
})();