本帖最后由 YWQ8 于 2023-11-25 01:17 编辑
游戏网页:https://www.webhek.com/post/color-test/
朋友在玩这个小游戏,看到颜色块是单独的标签,所以很容易可以作弊让分数超过他,写了这个js脚本。
用油猴安装,安装后网页上出现三个按钮,对应三种作弊模式。
原理比较简单,遍历所有标签,找到rgb值不同的块即可。
[JavaScript] 纯文本查看 复制代码 // ==UserScript==
// @name 染色
// @namespace *://www.webhek.com/post/color-test/
// @version 0.1
// @description try to take over the world!
// @AuThor YWQ
// @match *://www.webhek.com/post/color-test/
// @Icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
function yyy()
{
setTimeout(yyy,100);
var ans;
for(var i=1;i<=3;i++){
var a=document.querySelector("#box > span:nth-child("+i+")").style.backgroundColor;
var b=document.querySelector("#box > span:nth-child("+(i+1)+")").style.backgroundColor
if(a==b)
{
ans=a;
break;
}
}
var res=1;
while(document.querySelector("#box > span:nth-child("+res+")").style.backgroundColor==ans)res++;
document.querySelector("#box > span:nth-child("+res+")").click();
}
function yao()
{
setTimeout(yao,100);
ywq();
}
function ywq(){
//setTimeout(ywq,100);
var ans;
for(var i=1;i<=3;i++){
var a=document.querySelector("#box > span:nth-child("+i+")").style.backgroundColor;
var b=document.querySelector("#box > span:nth-child("+(i+1)+")").style.backgroundColor
if(a==b)
{
ans=a;
break;
}
}
var res=1;
while(document.querySelector("#box > span:nth-child("+res+")").style.backgroundColor==ans)res++;
document.querySelector("#box > span:nth-child("+res+")").style.backgroundColor='rgb(255,255,255)';
}
// 添加按钮
document.querySelector("#overlay99").remove();//去广告
var btn = document.createElement('button');
btn.innerHTML = '单次提示';
btn.style.position = 'fixed';
btn.style.top = '50';
btn.style.left = '570';
btn.style.zIndex = '9999';
btn.addEventListener('click', function() {
// 在这里编写按钮点击后的操作
ywq();
});
document.body.appendChild(btn);
var btn1 = document.createElement('button');
btn1.innerHTML = '连续模式';
btn1.style.position = 'fixed';
btn1.style.top = '50';
btn1.style.left = '500';
btn1.style.zIndex = '9999';
btn1.addEventListener('click', function() {
// 在这里编写按钮点击后的操作
yao();
});
document.body.appendChild(btn1);
let wx=document.createElement('span');
wx.innerHTML='妖_';
wx.style.position = 'fixed';
wx.style.top = '50';
wx.style.left = '450';
wx.style.zIndex = '9999';
document.body.appendChild(wx);
var btn2 = document.createElement('button');
btn2.innerHTML = '疯狂模式';
btn2.style.position = 'fixed';
btn2.style.top = '75';
btn2.style.left = '500';
btn2.style.zIndex = '9999';
btn2.addEventListener('click', function() {
// 在这里编写按钮点击后的操作
yyy();
});
document.body.appendChild(btn2);
})(); |