Script Archived
This script has been archived by the author. The script may be no longer functional, and the author no longer maintains it. You cannot provide feedback for this script.
// ==UserScript==
// @name 宝可梦点击(Poke Clicker)辅助脚本 野外离线战斗模块
// @namespace PokeClickerHelper
// @version 0.4.2
// @description 仅计算离线野外自动战斗,转化为在线自动战斗。额外功能:0延迟捕捉、自动购买高级球
// @author DreamNya
// @match https://www.pokeclicker.com
// @match https://g8hh.github.io/pokeclicker/
// @match https://pokeclicker.g8hh.com
// @match https://yx.g8hh.com/pokeclicker/
// @match https://dreamnya.github.io/pokeclicker/
// @icon data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/319hf99fYX/fX2F/319hf8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////99fYX/fX2F/319hf8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////wAAAP8AAAD/fX2F/319hf99fYX/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////8AAAD/AAAA/wAAAP99fYX/fX2F/wAAAP8AAAD/AAAA/319hf8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAP8AAAD/HBT//xwU//8AAAD//////319hf8AAAD/Dgim/w4Ipv8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAD/HBT//xwU//8cFP//HBT//wAAAP8AAAD/Dgim/w4Ipv8OCKb/Dgim/wAAAP8AAAAAAAAAAAAAAAAAAAAAAAAA/xwU//8cFP//HBT//xwU/44cFP//HBT//xwU//8cFP//Dgim/w4Ipv8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/HBT//xwU/47/////HBT/jhwU//8cFP//HBT//w4Ipv8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/xwU//8cFP//HBT/jhwU//8OCKb/Dgim/w4Ipv8OCKb/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/xwU//8OCKb/Dgim/w4Ipv8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/wAAAP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAPw/AADwDwAA4AcAAOAHAADAAwAAwAMAAMADAADAAwAA4AcAAOAHAADwDwAA/D8AAP//AAD//wAA//8AAA==
// @grant none
// @license MIT
// @run-at document-end
// ==/UserScript==
/* eslint-env jquery */
/* global player, numberOfPokemonDefeated, GameConstants, Settings, Battle, PokeClickerHelper, NotificationConstants, DungeonBattle, MapHelper*/
if (typeof PokeClickerHelper == typeof void 0) {
alert('宝可梦点击(Poke Clicker)辅助脚本 野外离线战斗模块加载失败\n\n未找到核心模块,需要先安装核心模块才可正常使用\n\n论坛主页:https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=3842')
window.open("https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=3842")
return
}
//劫持Game.computeOfflineEarnings
const customFuc = () => {
PokeClickerHelper.Notify({ message: `离线期间自动点击击败了: ${numberOfPokemonDefeated.toLocaleString('en-US')} 只宝可梦\n 开始计算离线战斗……期间请勿离开当前野外道路\n预计花费:${2 * numberOfPokemonDefeated}~${5 * numberOfPokemonDefeated}ms`, timeout: 60000, type: NotificationConstants.NotificationOption.info })
let start
const showCurrencyGainedAnimation = Settings.getSetting('showCurrencyGainedAnimation').value
if (showCurrencyGainedAnimation) Settings.setSettingByName('showCurrencyGainedAnimation', false) //关闭货币动画
//防止移动
const { moveToRoute, moveToTown } = MapHelper
MapHelper.moveToRoute = () => { }
MapHelper.moveToTown = () => { }
const fuc = () => {
start = Date.now() //记录载入时间
$('#PokeClickerHelperWharf').hide() //隐藏码头防止手贱炸出MissingNo
calcOffine(0, numberOfPokemonDefeated)
}
PokeClickerHelper.initAfterStartList.add(fuc)
function calcOffine(times, total) {
let _times = Math.max(1000 - (total - times), 0)
const thisTime = 1000 - _times
const _start = Date.now()
for (; _times < 1000; _times++) {
//if (App.game.breeding.eggList.find(i=>i().progress()>=100))break
Battle.hook_defeatPokemon()
}
const _end = Date.now()
if (times == 0) {
PokeClickerHelper.Notify({ message: `实时离线战斗进度 ${times + thisTime} / ${total}\n本次花费:${_end - _start}ms 目前总花费:${_end - start}ms\n平均花费:${Math.floor((_end - start) / (times + thisTime))}ms`, timeout: (_end - _start) / thisTime * total * 1000, type: NotificationConstants.NotificationOption.info })
} else {
$('.toast-body:contains("实时离线战斗进度")').html(`实时离线战斗进度 ${times + thisTime} / ${total}<br>本次花费:${_end - _start}ms 目前总花费:${_end - start}ms<br>平均花费:${Math.floor((_end - start) / (times + thisTime))}ms`)
}
times += thisTime
if (times < total) {
setTimeout(() => calcOffine(times, total), 500) //下一次1000次循环
} else {
const end = Date.now() //记录完成时间
if (showCurrencyGainedAnimation) Settings.setSettingByName('showCurrencyGainedAnimation', true)
MapHelper.moveToRoute = moveToRoute
MapHelper.moveToTown = moveToTown
$('#PokeClickerHelperWharf').show()
PokeClickerHelper.Notify({ message: `离线战斗计算完毕,现在可以正常游戏\n(测试版不保证无BUG 如有BUG欢迎反馈)\n离线计算:${numberOfPokemonDefeated}次,实际花费:${end - start}ms,平均花费:${Math.floor((end - start) / numberOfPokemonDefeated)}ms`, timeout: 60000, type: NotificationConstants.NotificationOption.info })
}
}
};
const customText = PokeClickerHelper.HookFucBody(customFuc);
const gameReplacement = [["const routeMoney = PokemonFactory.routeMoney(player.route(), player.region, false);", "if(player.route()){" + customText + "}else{const routeMoney = PokemonFactory.routeMoney(player.route(), player.region, false);"],
[/$/, "}"]];
const hookGame = function (Game) {
PokeClickerHelper.HookFuc(Game, 'computeOfflineEarnings', gameReplacement, '');
};
//读取野外离线战斗模块开关
let OfflineSwitch = JSON.parse(PokeClickerHelper.get('OfflineSwitch', "true"))
if (OfflineSwitch) PokeClickerHelper.addHook('Game', hookGame);
//劫持Battle.defeatPokemon hook野外0延迟捕捉
const defeatReplacement = [["setTimeout(() => {\n this.attemptCatch(enemyPokemon, catchRoute, region);\n if (Battle.route != 0) {\n this.generateNewEnemy();\n }\n }, App.game.pokeballs.calculateCatchTime(pokeBall));", "\n this.attemptCatch(enemyPokemon, catchRoute, region);\n if (Battle.route != 0) {\n this.generateNewEnemy();\n }\n ;"]];
PokeClickerHelper.HookFuc(Battle, 'defeatPokemon', defeatReplacement, '');
//劫持DungeonBattle.defeatPokemon hook地牢0延迟捕捉
const dungeonDefeatReplacement = [["setTimeout(() => {\n this.attemptCatch(enemyPokemon, route, region);\n if (DungeonRunner.defeatedBoss()) {\n DungeonRunner.dungeonWon();\n }\n }, App.game.pokeballs.calculateCatchTime(pokeBall));", " this.attemptCatch(enemyPokemon, route, region);\n if (DungeonRunner.defeatedBoss()) {\n DungeonRunner.dungeonWon();\n }\n ;"]];
PokeClickerHelper.HookFuc(DungeonBattle, 'defeatPokemon', dungeonDefeatReplacement, '');
//劫持Battle.prepareCatch hook自动购买高级球
const prepareCatch = [[/$/, 'ItemList.Ultraball.buy(1)']]
PokeClickerHelper.HookFuc(Battle, 'prepareCatch', prepareCatch, 'enemyPokemon, pokeBall');
//UI相关
const listener = () => {
//真0延迟捕捉 直接把捕捉动画代码全干了【……
$('#PokeClickerHelperNoDelayCatch').on('change', function () {
if (this.checked) {
PokeClickerHelper.applyHook(Battle, 'defeatPokemon')
PokeClickerHelper.applyHook(DungeonBattle, 'defeatPokemon')
} else {
PokeClickerHelper.restoreHook(Battle, 'defeatPokemon')
PokeClickerHelper.restoreHook(DungeonBattle, 'defeatPokemon')
}
})
//自动购买高级球
$('#PokeClickerHelperBuyUltraball').on('change', function () {
if (this.checked) {
PokeClickerHelper.applyHook(Battle, 'prepareCatch')
} else {
PokeClickerHelper.restoreHook(Battle, 'prepareCatch')
}
})
$('#PokeClickerHelperNoDelayCatch').prop('checked', JSON.parse(PokeClickerHelper.get('NoDelayCatch', 'false'))).change()
$('#PokeClickerHelperBuyUltraball').prop('checked', JSON.parse(PokeClickerHelper.get('BuyUltraball', 'false'))).change()
$('#PokeClickerHelperOfflineSwitch').prop('checked', OfflineSwitch)
}
const fuc = () => {
const text = `<tr id="PokeClickerHelperOfflineContainer"><td colspan="12"><div><label class="form-check-label ml-3 mr-1" title="直接取消野外及地牢中捕捉动画实现真正0延迟"><input id="PokeClickerHelperNoDelayCatch" type="checkbox" value="false">0 延迟捕捉</label><label class="form-check-label ml-4 mr-1" title="消耗任意1个精灵球后自动购买1个高级球(不考虑购买价格,建议不要手动购买)"><input id="PokeClickerHelperBuyUltraball" type="checkbox" value="false">自动购买高级球</label><label class="form-check-label ml-4 mr-1" title="开启后会自动计算离线期间野外杀怪并转化为在线杀怪(无法获得DreamOrb)"><input id="PokeClickerHelperOfflineSwitch" type="checkbox" value="true">野外离线战斗</label></div></td></tr>`
$("#pokeballSelectorBody thead").append(text)
}
PokeClickerHelper.UIContainerID.push("#PokeClickerHelperOfflineContainer");
PokeClickerHelper.UIstyle.push(`#PokeClickerHelperOfflineContainer input[type=checkbox]{position: absolute;margin-top: 0.24rem;margin-left: -1rem;}`);
PokeClickerHelper.UICustomFuc.push(fuc);
PokeClickerHelper.UIlistener.push(listener);