ws
// ==UserScript==
// @name ws
// @namespace http://tampermonkey.net/
// @version 0.2
// @description
// @author You
// @match https://wavesducks.com/promo/**
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @license MIT
// @require http://code.jquery.com/jquery-1.11.0.min.js
// @require https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js
// ==/UserScript==
function qSelector(selector) {
return document.querySelector(selector);
}
function qSelectorAll(selector) {
return document.querySelectorAll(selector);
}
/**
* 睡眠函数
* @param numberMillis -- 要睡眠的毫秒数
*/
function sleep(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
window.alert = function(){return true};
Window.prototype.alert = function(){return true};
Window.prototype.confirm = function(){return true};
window.confirm = function(){return true};
(async function () {
'use strict';
var chooseFlag = false;
const choose_duck_tab = ".choose-duck__tabs__tab"
const ducks_card = ".choose-duck__ducks__card"
const choose_duck_refresh = ".choose-duck__refresh"
const WAIT_LOADING = ".HUD_loading__2xfnW"
const lose_btn = ".lost__btn"
const win_button = ".btn.mt-4.mb-4"
const target_point = ".TargetPoints_count__1QWDl"
const def_point = ".TargetPoints_Defense__3UHyz"
const attack_point = ".TargetPoints_Attack__2eXNC"
const point_buttons = ".TargetPoints_target__1uLes"
const make_turn_button_clickable = ".Gameplay_makeTurn__mGBeP:not(:disabled)"
const make_turn_button_disable = ".Gameplay_makeTurn__mGBeP:disabled"
const make_turn_button = ".Gameplay_makeTurn__mGBeP"
const MY_HAND = ".Hand_root__3x64o :first"
const FIGHT_PRICE = ".choose-duck-info__el__value"
const HEADER = ".choose-duck__duck-wars-logo"
const LAP = ".choose-duck__duck-wars-logo__img"
const CHOOSE_CAPTCHA = ".choose-duck__duck-wars-logo"
const BASIC_CARD = ["Ultimate", "Attack", "Defense", "Heal"]
const GENES_CARD = ["Reflector", "Balance Stance", "Sniper", "Hit And Run", "Average", "Love", "Berserk", "Defender"]
const GENERATION_CARD = ["Love", "Swirl", "Fortress", "Sharp Wall", "Stone Wall", "Perfect Balance", "Double-Hit", "Safe Is Priority", "Mega Heal"]
const ACHIEVEMENT_CARD = ["Rarity Destroyer","Billionaire Boys Club", "Anniversary Duck","Colored Anniversary", "DNA Guard", "Pioneer", "fight.move_Valentine", "First type","Xmas rage","LastTrain","The first duck","Grown up","High Five"]
const INIT_STATE = 1
const CHOOSE_DUCK_STATE = 2
const FIGHT_WAIT_STATE = 3
const FIGHT_STATE = 4
const FIGHT_START_PRICE = 0.000002
var currentState = INIT_STATE
var farmNum = 1
var time
var fightPrice = 0
var hour
var turnClicked=false
var fightTimeOut = 0
var captchaTimeOut = 0
setInterval(function () {
try {
$(LAP).css('display','none');
$(HEADER).css('display','none');
if ($("span:contains('BlackTurtle Farm')").length > 0) {
if (farmNum === 1) {
$("span:contains('FOMO Farms')").parent().siblings("button").click()
} else if (farmNum === 2) {
$("span:contains('BlackTurtle Farm')").parent().siblings("button").click()
} else if (farmNum === 3) {
$("span:contains('Mundocrypto Farm')").parent().siblings("button").click()
} else if (farmNum === 4) {
$("span:contains('Duxplorer.com community farm')").parent().siblings("button").click()
} else if(farmNum === 5) {
$("span:contains('Marvin Favis Farm')").parent().siblings("button").click()
}else if(farmNum === 6){
$("span:contains('KOLKHOZ')").parent().siblings("button").click()
}
}
if ($(make_turn_button_clickable).length > 0) {
$(make_turn_button_clickable).click()
}
if (qSelector(lose_btn)) {
qSelector(lose_btn).click()
currentState=INIT_STATE
}
if (qSelector(win_button)) {
qSelector(win_button).click()
currentState=INIT_STATE
}
if(qSelector(choose_duck_tab)){
qSelector(choose_duck_tab).click()
}
} catch (err) {
console.log(err.message)
}
}, 500)
setInterval(function (){
if(currentState===CHOOSE_DUCK_STATE){
if (qSelector(ducks_card)) {
var num = Math.floor(Math.random()*2)
$(ducks_card)[0].click()
qSelector(choose_duck_refresh).click()
}
if(qSelector(WAIT_LOADING)){
currentState=FIGHT_WAIT_STATE
}
}
},1000)
setInterval( function () {
try {
time = new Date().getMinutes();
hour = new Date().getHours();
// if ((time >= 15 && time <= 23) || (time >= 45 && time <= 53) || ((hour === 3 || hour === 9 || hour === 15 || hour === 21) && (time >= 8 && time <= 15))){
//waitKeyElement(choose_duck_tab,20000)
if(qSelector(ducks_card)){
captchaTimeOut=0
currentState=CHOOSE_DUCK_STATE
}
if(currentState===FIGHT_WAIT_STATE){
// waitKeyElementJq(MY_HAND,80000)
currentState=FIGHT_STATE
}
if(currentState===FIGHT_STATE){
fightTimeOut=fightTimeOut+1
if ($(MY_HAND).length > 0) {
var attackPoint = $(attack_point).find(target_point)[0]
var defPoint = $(def_point).find(target_point)[0]
if (attackPoint) {
var pointButton = $(attack_point).find(point_buttons)
if (attackPoint.innerText === "1" || attackPoint.innerText === "-1") {
var point = Math.round(Math.random() * 2);
pointButton[point].click()
} else if (attackPoint.innerText === "2") {
var num = Math.round(Math.random() * 2);
if (num === 0) {
pointButton[0].click()
pointButton[1].click()
} else if (num === 1) {
pointButton[0].click()
pointButton[2].click()
} else {
pointButton[0].click()
pointButton[3].click()
}
}
}
if (defPoint) {
var pointButton = $(def_point).find(point_buttons)
if (defPoint.innerText === "1"||defPoint.innerText === "-1") {
var point = Math.round(Math.random() * 2);
pointButton[point].click()
} else if (defPoint.innerText === "2") {
var num = Math.round(Math.random() * 2);
if (num === 0) {
pointButton[0].click()
pointButton[1].click()
} else if (num === 1) {
pointButton[0].click()
pointButton[2].click()
} else {
pointButton[0].click()
pointButton[3].click()
}
}
}
if (!$(make_turn_button).length > 0) {
chooseFlag = false
var count = Math.round(Math.random() * 6)
if(count>2){
for (var i = 0; i < ACHIEVEMENT_CARD.length; i++) {
var cardName = ACHIEVEMENT_CARD[i]
// var myHand = $(HAND)[0]
var card = $(MY_HAND).find("h2:contains('" + cardName + "')").parent().parent()
if (card.length > 0) {
card.click()
console.log("choose card:" + cardName)
chooseFlag = true
break;
}
}
if (!chooseFlag) {
for (var i = 0; i < GENERATION_CARD.length; i++) {
var cardName = GENERATION_CARD[i]
// var myHand = $(HAND)[0]
var card = $(MY_HAND).find("h2:contains('" + cardName + "')").parent().parent()
if (card.length > 0) {
card.click()
console.log("choose card:" + cardName)
chooseFlag = true
break;
}
}
}
if (!chooseFlag) {
for (var i = 0; i < GENES_CARD.length; i++) {
var cardName = GENES_CARD[i]
// var myHand = $(HAND)[0]
var card = $(MY_HAND).find("h2:contains('" + cardName + "')").parent().parent()
if (card.length > 0) {
card.click()
console.log("choose card:" + cardName)
chooseFlag = true
break;
}
}
}
if (!chooseFlag) {
for (var i = 0; i < BASIC_CARD.length; i++) {
var cardName = BASIC_CARD[i]
// var myHand = $(HAND)[0]
var card = $(MY_HAND).find("h2:contains('" + cardName + "')").parent().parent()
if (card.length > 0) {
card.click()
console.log("choose card:" + cardName)
chooseFlag = true
break;
}
}
}
}else {
if (!chooseFlag) {
$(MOVE_CARD)[count].click()
chooseFlag = true
}
}
}
}
// }
}
} catch (err) {
console.log(err.message)
}
}, 500)
})();