// ==UserScript==
// @name [Pokeclicker] Catch Speed Adjuster
// @namespace Pokeclicker Scripts
// @author Ephenia
// @description Adjusts catch speed of all Pokeballs. Currently only makes Pokeballs catch as fast as possible.
// @copyright https://github.com/Ephenia
// @license GPL-3.0 License
// @version 1.4.3
// @homepageURL https://github.com/Ephenia/Pokeclicker-Scripts/
// @supportURL https://github.com/Ephenia/Pokeclicker-Scripts/issues
// @match https://www.pokeclicker.com/
// @icon https://www.google.com/s2/favicons?domain=pokeclicker.com
// @grant unsafeWindow
// @run-at document-idle
// @downloadURL https://update.greasyfork.icu/scripts/435872/%5BPokeclicker%5D%20Catch%20Speed%20Adjuster.user.js
// @updateURL https://update.greasyfork.icu/scripts/435872/%5BPokeclicker%5D%20Catch%20Speed%20Adjuster.meta.js
// ==/UserScript==
var ballAdjuster;
var defaultTime = [];
function initBallAdjust() {
var getBalls = App.game.pokeballs.pokeballs;
for (var i = 0; i < getBalls.length; i++) {
defaultTime.push(getBalls[i].catchTime)
}
var ballCont = document.getElementById('pokeballFilters');
var ballAdj = document.createElement("tr");
ballAdj.innerHTML = `
| `
ballCont.append(ballAdj)
document.getElementById('ball-adjust').addEventListener('click', event => changeAdjust(event.target));
if (ballAdjuster) {
document.getElementById('ball-adjust').checked = true;
catchDelay();
}
function changeAdjust(ele) {
ballAdjuster = !ballAdjuster;
localStorage.setItem("ballAdjuster", ballAdjuster);
catchDelay();
}
function catchDelay() {
for (var i = 0; i < getBalls.length; i++) {
if (ballAdjuster) {
getBalls[i].catchTime = 0;
} else {
getBalls[i].catchTime = defaultTime[i];
}
}
}
}
if (localStorage.getItem('ballAdjuster') == null) {
localStorage.setItem('ballAdjuster', 'false');
}
ballAdjuster = localStorage.getItem('ballAdjuster') == 'true';
function loadEpheniaScript(scriptName, initFunction, priorityFunction) {
function reportScriptError(scriptName, error) {
console.error(`Error while initializing '${scriptName}' userscript:\n${error}`);
Notifier.notify({
type: NotificationConstants.NotificationOption.warning,
title: scriptName,
message: `The '${scriptName}' userscript crashed while loading. Check for updates or disable the script, then restart the game.\n\nReport script issues to the script developer, not to the Pokéclicker team.`,
timeout: GameConstants.DAY,
});
}
const windowObject = !App.isUsingClient ? unsafeWindow : window;
// Inject handlers if they don't exist yet
if (windowObject.epheniaScriptInitializers === undefined) {
windowObject.epheniaScriptInitializers = {};
const oldInit = Preload.hideSplashScreen;
var hasInitialized = false;
// Initializes scripts once enough of the game has loaded
Preload.hideSplashScreen = function (...args) {
var result = oldInit.apply(this, args);
if (App.game && !hasInitialized) {
// Initialize all attached userscripts
Object.entries(windowObject.epheniaScriptInitializers).forEach(([scriptName, initFunction]) => {
try {
initFunction();
} catch (e) {
reportScriptError(scriptName, e);
}
});
hasInitialized = true;
}
return result;
}
}
// Prevent issues with duplicate script names
if (windowObject.epheniaScriptInitializers[scriptName] !== undefined) {
console.warn(`Duplicate '${scriptName}' userscripts found!`);
Notifier.notify({
type: NotificationConstants.NotificationOption.warning,
title: scriptName,
message: `Duplicate '${scriptName}' userscripts detected. This could cause unpredictable behavior and is not recommended.`,
timeout: GameConstants.DAY,
});
let number = 2;
while (windowObject.epheniaScriptInitializers[`${scriptName} ${number}`] !== undefined) {
number++;
}
scriptName = `${scriptName} ${number}`;
}
// Add initializer for this particular script
windowObject.epheniaScriptInitializers[scriptName] = initFunction;
// Run any functions that need to execute before the game starts
if (priorityFunction) {
$(document).ready(() => {
try {
priorityFunction();
} catch (e) {
reportScriptError(scriptName, e);
// Remove main initialization function
windowObject.epheniaScriptInitializers[scriptName] = () => null;
}
});
}
}
if (!App.isUsingClient || localStorage.getItem('catchspeedadjuster') === 'true') {
loadEpheniaScript('catchspeedadjuster', initBallAdjust);
}