Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Fuck Da Man lulz
- // @namespace https://tampermonkey.net/
- // @version 2.0
- // @match https://pokemoncreed.net/battle.php*
- // @match https://pokemoncreed.net/profile.php*
- // @grant none
- // @require http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
- // ==/UserScript==
- var API_KEY = '6719dbc1561263aae9c42965a78c8b37';
- var attackFunctionStr =
- 'function attack(){\n' +
- 'document.getElementById(\'loading\').style.display = "";\n' +
- 'document.getElementById(\'moves\').style.display = "none";\n' +
- 'document.getElementById(\'moves2\').style.display = "none";\n' +
- 'return true;\n' +
- '}';
- function battle() {
- if (isError()) {
- console.error('Error occurred');
- confirm('Error occurred');
- } else if (isFrozen()) {
- console.error('Your account has been frozen');
- confirm('Your account has been frozen');
- } else if (isCaptchaActive()) {
- solveCaptcha();
- } else if (isResendAction()) {
- resendAction();
- } else if (hasBattleEnded()) {
- restartBattle();
- } else if (canContinueBattle()) {
- continueBattle();
- } else if (!window.attack) {
- console.error('window.attack not present');
- confirm('window.attack not present');
- return;
- } else if (window.attack.toString() !== attackFunctionStr) {
- console.error('window.attack has been changed', window.attack, window.attack.toString());
- confirm('window.attack has been changed');
- return;
- } else {
- var $yourRoster = $('tr td[style="vertical-align: top; text-align: center; padding: 3px"]:nth-child(1)');
- var yourRosterLinks = $yourRoster.find('a').toArray();
- var yourSlotHP6 = $yourRoster.find('div[style*="width: 100px; border: 1px solid red; float: right; text-align: left"] img[src="hp.gif"]').width();
- var yourPokeIsFainted = !!$('.battlefast th[width="50%"]:nth-child(1) img[src*="img/types/fnt.png"]')[0];
- var enemyPokeIsPoisoned = !!$('.battlefast th[width="50%"]:nth-child(2) img[src*="img/types/psn.png"]')[0];
- var enemySlotHP1 = $($('tr td[style="vertical-align: top; text-align: center; padding: 3px"]:nth-child(2)').find('div[style*="width: 100px; border: 1px solid red; float: right; text-align: left"] img[src="hp.gif"]').toArray()[0]).width();
- if (!enemyPokeIsPoisoned) {
- if (yourSlotHP6 !== 100 || yourPokeIsFainted) {
- console.log('Enemy is not poisoned and slot 6 has taken damage. Restart battle.');
- restartBattle();
- } else {
- console.log('Enemy is not poisoned. Trying to use Toxic.');
- if (getMove('Toxic')) {
- useMove(getMove('Toxic'));
- } else {
- if (yourRosterLinks[4]) {
- console.log('Pokemon does not have Toxic. Switching to slot 6.');
- yourRosterLinks[4].click();
- } else {
- console.log('Pokemon does not have Toxic and slot 6 is fainted. Using a random move.');
- useRandomMove();
- }
- }
- }
- } else if (!yourPokeIsFainted) {
- if (!getMove('Fly')) {
- console.log('Pokemon does not have Fly. Using a random move.');
- useRandomMove();
- } else if (enemySlotHP1 <= 10) {
- console.log('Enemy Pokemon HP is at 10% or less. Switching to slot 1.');
- yourRosterLinks[0].click();
- } else {
- useMove(getMove('Fly'));
- }
- } else {
- console.log('Enemy is poisoned and your Pokemon has fainted. Switch to the next available Pokemon.');
- $yourRoster.find('a').toArray().reverse()[0].click();
- }
- }
- }
- function canContinueBattle() {
- return !!getContinueBattleLink();
- }
- function continueBattle() {
- console.log('continue battle');
- getContinueBattleLink().click();
- }
- function getContinueBattleLink() {
- return $('a:contains("Continue Battle")')[0];
- }
- function hasBattleEnded() {
- return !$('tr td[style="vertical-align: top; text-align: center; padding: 3px"]:nth-child(1)').find('div[style*="width: 100px; border: 1px solid red; float: right; text-align: left"] img[src="hp.gif"]').toArray().map(img => $(img).width()).find(w => w) || $('.battlefast td.bord:visible[colspan=3][style="text-align: center"]').text().includes("Foe Mysterious Trainer's Mew fainted.");
- }
- function restartBattle() {
- $('button:visible:contains("Restart Battle")[onclick*="window.location"][class="button"]').click();
- }
- function isError() {
- return !!$('.title:contains("An Error Occured")')[0];
- }
- function isFrozen() {
- return !!$('.title:contains("Frozen")')[0];
- }
- function isCaptchaActive() {
- return !!$('.title:contains("Verification Code")')[0];
- }
- function isResendAction() {
- return !!$('input:visible[type=submit][name=restoreform][value="Resend Action"]')[0];
- }
- function resendAction() {
- $('input:visible[type=submit][name=restoreform][value="Resend Action"]').click();
- }
- function getMove(moveName) {
- var foundMove = false;
- $('tr[id*="moves"] form:visible[action*="battle.php?c="][method="POST"][onsubmit="return attack();"]').each(function () {
- var $moveButton = $(this).find('input:visible[type=submit][value*="'+moveName+'"]');
- if ($moveButton[0]) {
- foundMove = $moveButton[0];
- return;
- }
- });
- return foundMove;
- }
- function useMove(moveButton) {
- if (!moveButton) {
- console.error('Move does not exist', moveButton);
- confirm('Move does not exist');
- return;
- }
- console.log('Use move', moveButton);
- $(moveButton).click();
- }
- function useRandomMove() {
- var moveButton = $('tr form:visible[action*="battle.php?c="][method="POST"][onsubmit="return attack();"]:nth-child(1) input:visible[type=submit]')[Math.floor(Math.random() * 4) + 0];
- useMove(moveButton);
- }
- function solveCaptcha() {
- console.log('Trying to solve captcha.');
- toDataURL(
- $('.contentcontent .ranks tbody tr th img:visible[src*="captcha/captcha.php?t="]').attr('src'),
- function(dataUrl) {
- $.ajax('https://2captcha.com/in.php', {
- method: 'POST',
- dataType: 'json',
- data: {
- key: API_KEY,
- method: 'base64',
- json: 1,
- header_acao: 1,
- body: dataUrl
- },
- success: checkCaptcha
- });
- }
- );
- }
- function checkCaptcha(data) {
- console.log('Requested a captcha be solved. Now we wait for it.', data);
- setTimeout(function () {
- if (data.status != '1') {
- console.error('Error solving captcha', data);
- confirm('Error solving captcha, check console');
- return;
- }
- $.ajax('https://2captcha.com/res.php', {
- method: 'GET',
- dataType: 'json',
- data: {
- key: API_KEY,
- action: 'get',
- id: data.request,
- json: 1,
- header_acao: 1
- },
- success: function (data2) {
- if (data2.status == '1') {
- console.log('Captcha solved', data2);
- $('.contentcontent .ranks input:visible[type=text][class=text][name=captcha]').val(data2.request);
- $('.contentcontent .ranks input:visible[type=submit][name=button][value=Submit][class=button]').click();
- } else {
- console.warn('Captcha not solved yet, retrying', data2);
- checkCaptcha(data);
- }
- }
- });
- }, Math.floor(Math.random() * 2500) + 5000);
- }
- function toDataURL(src, callback, outputFormat) {
- var img = new Image();
- img.crossOrigin = 'Anonymous';
- img.onload = function() {
- var canvas = document.createElement('CANVAS');
- var ctx = canvas.getContext('2d');
- var dataURL;
- canvas.height = this.naturalHeight;
- canvas.width = this.naturalWidth;
- ctx.drawImage(this, 0, 0);
- dataURL = canvas.toDataURL(outputFormat);
- callback(dataURL);
- };
- img.src = src;
- if (img.complete || img.complete === undefined) {
- img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
- img.src = src;
- }
- }
- var timeout = Math.floor(Math.random() * 650) + 1000;
- if (Math.floor(Math.random() * 100) == 1) {
- timeout = Math.floor(Math.random() * 5000) + 5000;
- }
- setTimeout(() => {
- battle();
- }, timeout);
Add Comment
Please, Sign In to add comment