Advertisement
AgarB13

AgarB13|EXTENSION

Mar 13th, 2016
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.08 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AgarB13 EXTENSION
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Bom Proveito
  6. // @author AgarB13
  7. // @match http://*agar.io/*
  8. // @grant none
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. 'use strict';
  12.  
  13. var lastEdit = 1457530046176;
  14. var respawnLoop = null, ejectorLoop = null, randomMoveLoop = null;
  15. var overlayClosed = false, spectatorMode = false;
  16. var holdingKey = {};
  17. var canvas = document.getElementById('canvas');
  18.  
  19. $(document).ready(function() {
  20.  
  21. window.onbeforeunload = function() { return 'Quit game?'; };
  22. window.setAutoSpawn = function(e) {
  23. if(e) { if(!respawnLoop) respawnLoop = setInterval(startGame, 1000); }
  24. else { clearInterval(respawnLoop); respawnLoop = null; }
  25. };
  26. window.joinNewRoom = function() {
  27. var s = $('#gamemode').val();
  28. setGameMode(':party');
  29. setGameMode(s);
  30. };
  31. window.setSpectatorMode = function(e) { spectatorMode = e; };
  32. window.setRandomMove = function(e) {
  33. if(e) { if(!randomMoveLoop) randomMoveLoop = setInterval(randomMove, 5000); }
  34. else { clearInterval(randomMoveLoop); randomMoveLoop = null; }
  35. };
  36. window.scriptInfo = function() { $('#infoPanel').fadeToggle(); };
  37. window.toggleShowHide = function() {
  38. var az = $('#infoPanel-content a').next();
  39. if(az.is(':visible')) { az.slideUp('fast'); az.prev().html('Show'); }
  40. else { az.slideDown('fast'); az.prev().html('Hide'); }
  41. };
  42.  
  43. $(document).on('keydown', function(evt) {
  44. var key = evt.which || evt.keyCode;
  45. var exKey = evt.ctrlKey || evt.shiftKey || evt.altKey;
  46. //console.log(key + ' ' + exKey + ' (' + evt.ctrlKey + ' ' + evt.shiftKey + ' ' + evt.altKey + ')');
  47. if($('#overlays').is(':hidden') && !exKey) {
  48. if(key == 27) { // KEY_ESC
  49. overlayClosed = false;
  50. setTimeout(function() { $('button[data-itr="spectate"]').removeAttr('disabled'); }, 100);
  51. }
  52. else if(key == 69) { // KEY_E
  53. if(!ejectorLoop) {
  54. ejectorLoop = setInterval(function() { sendEject(); }, 10);
  55. }
  56. }
  57. if(!holdingKey[key]) {
  58. if(key == 82) { // KEY_R
  59. for(var n = 1; n <= 7; n++) {
  60. setTimeout(function() { sendEject(); }, 125 * n);
  61. }
  62. }
  63. else if(key == 84) { // KEY_T
  64. for(var n = 1; n <= 4; n++) {
  65. setTimeout(function() { sendMitosis(); }, 60 * n);
  66. }
  67. }
  68. else if(key == 83) { // KEY_S
  69. var newPos = {clientX: innerWidth / 2, clientY: innerHeight / 2};
  70. canvas.onmousedown(newPos);
  71. }
  72. else if(key == 67) { // KEY_C
  73. var newPos = {screenX: innerWidth / 2, screenY: innerHeight / 2};
  74. canvas.onmousedown(newPos);
  75. }
  76. else if(key == 86) { showPanels(2); } // KEY_V
  77. else if(key == 66) { showPanels(1); } // KEY_B
  78. else if(key == 78) { showPanels(3); } // KEY_N
  79. else if(key == 77) { showPanels(4); } // KEY_M
  80. else if(key == 188) { showPanels(5); } // KEY_,
  81. }
  82. holdingKey[key] = true;
  83. }
  84. });
  85. $(document).on('keyup', function(evt) {
  86. var key = evt.which || evt.keyCode
  87. holdingKey[key] = false;
  88. if(key == 69) { // KEY_E
  89. clearInterval(ejectorLoop);
  90. ejectorLoop = null;
  91. }
  92. });
  93.  
  94. editPanel();
  95. setTimeout(applyConfig, 100);
  96. hookOverlay();
  97.  
  98. });
  99.  
  100. function editPanel() {
  101. var btnGroup = $('#agario-main-buttons div').eq(0).children();
  102. btnGroup.eq(1).css('width', '230px');
  103. btnGroup.eq(2).css('width', '112px');
  104. btnGroup.eq(3).css('width', '112px').after('<button style="height: 35px; display: block; float: right;" class="btn btn-success btn-refresh" onclick="joinNewRoom(); return false;"><i class="glyphicon glyphicon-refresh"></i></button>');
  105.  
  106. $('#helloContainer').css('height', '');
  107. $('#adbg').parent().hide().css('visibility', 'hidden');
  108. $('.agario-promo').hide().css('visibility', 'hidden');
  109. $('#agario-web-incentive').hide().css('visibility', 'hidden');
  110. $('#connecting').css({'top': '13px', 'right': '185px', 'bottom': '', 'left': '', 'font-size': '13px'});
  111. $('#connecting h2').css({'display': 'inline-block'}).after('<span id="connectingToInfo" style="position: absolute; top: 5px; right: 15px;"></span>');
  112.  
  113. $('#nick').attr('name', 'nick');
  114. $('#quality').css({'margin': '6px 0px'});
  115. $('#options').append('<label style="margin-top: 7px; padding-top: 7px; border-top: 1px dashed #888; width: 188px;"><input type="checkbox" onchange="setAcid($(this).is(\':checked\'));"><span data-itr="option_acid_mode">Acid mode</span></label><label style="width: 188px;"><input type="checkbox" onchange="setAutoSpawn($(this).is(\':checked\'));"><span data-itr="option_auto_spawn">Auto respawn</span></label><label style="width: 188px;"><input type="checkbox" onchange="setSpectatorMode($(this).is(\':checked\'));"><span data-itr="option_spectator_mode">Spectate on join</span></label><label style="width: 188px;"><input type="checkbox" onchange="setRandomMove($(this).is(\':checked\'));"><span data-itr="option_random_move">Randomize movement</span></label>');
  116. $('#instructions center').after('<hr><div id="shortcuts" style="font-size: 85%;"><strong style="display: inline-block; width: 320px; text-align: center; padding-bottom: 10px;">Ingame Shortcuts</strong><br><span style="display: block; width: 160px; float: left;">E: Eject mass cont.</span><span style="display: block; width: 160px; float: left;">V: Skin panel</span><span style="display: block; width: 160px; float: left;">R: Eject mass 7 times</span><span style="display: block; width: 160px; float: left;">B: Shop panel</span><span style="display: block; width: 160px; float: left;">T: Split 4 times</span><span style="display: block; width: 160px; float: left;">N: XP Boost panel</span><span style="display: block; width: 160px; float: left;">S: Stop moving</span><span style="display: block; width: 160px; float: left;">M: Mass Boost panel</span><span style="display: block; width: 160px; float: left;">C: Go center of map</span><span style="display: block; width: 160px; float: left;">,: Free coins panel</span></div>');
  117. $('#instructions center span[class="text-muted"] b').css({'background-color': '#333', 'color': '#EEE', 'padding': '1px 5px', 'border-radius': '3px'});
  118. $('#instructions').append('<div id="script-info" style="font-size: 70%; float: right; margin: 23px 0px 6px 0px;">Script by condoriano. <a href="#" onclick="scriptInfo(); return false;">More Info</a></div>');
  119. $('#instructions').next().remove();
  120.  
  121. $('#stats').css('height', '375px');
  122. $('#stats hr').remove();
  123. $('#socialStats').css('bottom', '65px');
  124. $('#statsContinue').css('bottom', '25px');
  125. $('#statsGraph').css('bottom', '120px').attr('height', '200px');
  126. $('#s300x250').css('z-index', '-10');
  127. addInfoPanel();
  128.  
  129. $('footer').parent().append('<footer class="tosBox update"><a href="http://pastebin.com/raw.php?i=mkCsDgvd" target="_blank" class="text-muted" title="Last update: ' + timeSince(lastEdit) + ' ago">Source Code</a></footer>');
  130. $('footer').parent().append('<footer class="tosBox donate"><form id="donate-mod" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"><input name="cmd" value="_donations" type="hidden"><input name="business" value="keyzint@gmail.com" type="hidden"><input name="lc" value="US" type="hidden"><input name="item_name" value="Donation" type="hidden"><input name="no_note" value="0" type="hidden"><input name="currency_code" value="USD" type="hidden"><input name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest" type="hidden"><input name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal - The safer, easier way to pay online!" border="0" type="image"><img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" height="1" border="0" width="1"></form></footer>');
  131. $('footer.tosBox.left').removeClass('left').addClass('gamemode').css({'bottom': '30px', 'right': '0px', 'font-size': '12px', 'background-color': '#3071A9', 'border-radius': '15px 0px 0px 15px', 'padding-left': '18px'});
  132. $('footer.tosBox.right').removeClass('right').addClass('tos').css({'bottom': '0px', 'right': '0px', 'font-size': '12px', 'background-color': '#3071A9', 'border-radius': '15px 0px 0px 15px', 'padding-left': '18px'});
  133. $('footer.tosBox.update').css({'bottom': '0px', 'right': '280px', 'font-size': '12px', 'background-color': '#398439', 'border-radius': '5px 5px 0px 0px'});
  134. $('footer.tosBox.donate').css({'bottom': '-2px', 'right': '380px', 'font-size': '12px', 'background-color': 'transparent', 'padding': '0px'});
  135. $('footer.tosBox a').css('color', '#FFFFFF');
  136. }
  137.  
  138. function addInfoPanel() {
  139. var editedDate = new Date(lastEdit);
  140. $('footer').eq(0).before('<div id="infoPanel"><div id="infoPanel-header"><button onclick="scriptInfo(); return false;">X</button><h2>Script Info</h2><span title="' + editedDate.toString() + '">Last update: ' + timeSince(lastEdit) + ' ago</span></div><div id="infoPanel-content"></div><div id="infoPanel-footer"></div></div>');
  141. $('#infoPanel').css({'display': 'none', 'width': '820px', 'height': '500px', 'padding': '0px 20px', 'position': 'absolute', 'top': '50%', 'left': '50%', 'transform': 'translate(-50%, -50%)', 'background-color': '#123', 'color': '#AAA', 'border': '1px solid #000000', 'border-radius': '12px', 'box-shadow': '0px 0px 100px #012 inset'});
  142. $('#infoPanel-header').css({'font-family': 'Consolas', 'color': '#EEE', 'padding': '20px 0px', 'text-align': 'center', 'border-bottom': '2px solid #28B', 'position': 'relative'});
  143. $('#infoPanel-header button').css({'float': 'right', 'color': '#AAA', 'border': 'none', 'background-color': 'rgba(0, 0, 0, 0.3)', 'position': 'absolute', 'top': '10', 'right': '0'});
  144. $('#infoPanel-header h2').css({'margin': '0px'});
  145. $('#infoPanel-header span').css({'font-size': '80%', 'color': '#999'});
  146. $('#infoPanel-content').css({'font-family': 'Tahoma, sans-serif', 'width': '780px', 'height': '338px', 'overflow': 'auto', 'margin': '20px 0px'});
  147. $('#infoPanel-footer').css({'font-size': '80%'});
  148. $('#infoPanel-content').html('<div id="infoPanel-content-features"><span style="color: #EEE;">Features</span><ul><li>Auto-save game settings<ul><li>Settings are saved automatically every time you makeachange.</li><li>Default name is ௌௌௌௌௌௌௌௌௌௌௌௌௌௌௌ</li></ul></li><li>Auto respawn - Enabling this will also make the Score counter to show real-time mass.</li><li>Spectator Mode - Enabling this will put you into spectator mode when you join a server.</li><li>Randomize Movement - Enabling this will make your cells change direction randomly every 5 seconds. Useful when going AFK.</li><li>Acid Mode</li><li>Refresh server button</li><li>Prompt on tab close</li><li>Hide ads and promos</li><li>Various ingame keyboard shortcuts</li></ul></div>\
  149. <div id="infoPanel-content-changelogs"><span style="color: #EEE;">Changelog</span> <a href="#" onclick="toggleShowHide(); return false;" style="font-size: 11px;">Show</a><div style="display: none; width: 90%; background: rgba(0,0,0,0.3); font-size: 11px; padding: 10px"><ul style="padding-left: 20px;">\
  150. <li>2016-03-01<ul><li>Made all panels opened with the ingame shortcut to be semi-transparent</li><li>Added new feature - Press , to open free coin panel</li><li>Added new feature - Spectator Mode - You will be put into spectatormode when you join a server</li></ul></li>\
  151. <li>2015-02-19<ul><li>Added new feature - Press V to open skin panel</li><li>Added new feature - Press B to open shop panel</li><li>Added new feature - Press M to open mass boost panel</li><li>Added new feature - Press N to open xp panel</li><li>Removed checkboxes for ingame shortcut features - they are now not toggle-able</li><li>Reworked instruction UI</li></ul></li><li>2015-12-29<ul><li>Added new feature - Press R to eject mass 7 times</li><li>Added new fature - Press T to split 4 times</li></ul></li><li>2015-12-26<ul><li>Moved connecting panel to top right corner of the screen</li><li>Added region and gamemode info on connecting panel</li></ul></li><li>2015-12-24 - Added new feature - Acid mode</li><li>2015-12-23 - Resized stats panel to exclude ads height</li>\
  152. <li>2015-12-22<ul><li>Added new feature - Press S key to stop movement</li><li>Added new feature - Press C to go to the center of the map</li><li>Added new feature - Randomize movement - change direction every 5 seconds</li></ul></li><li>2015-12-18 - Added changelog into the info panel</li><li>2015-12-16 - Added info panel</li><li>2015-12-13 - Fixed gamemode not always changing to the saved value</li><li>2015-12-11 - Fixed not being able to spectate</li><li>2015-12-09 - Script is now hosted on pastebin to make updating easy</li><li>2015-12-08<ul><li>Fixed overlay not displayed on center y-axis</li><li>Updated link for update script url</li><li>Added donate button in the footer</li></ul></li>\
  153. <li>2015-12-06<ul><li>Added promo hiding</li><li>Stylized footer and moved it to the right</li></ul></li><li>2015-12-05<ul><li>Rewrote code to use jQuery</li><li>Fixed auto spawn not working for guest players</li><li>Added ads hiding feature</li><li>Added instruction for "hold E to W"</li><li>Added link to this page</li><li>Stylized instructions a little bit</li></ul></li><li>2015-12-02 - Added refresh server button</li><li>2015-12-01<ul><li>Fixed button style on chrome</li><li>Added "hold E to W" function</li><li>Removed debugging alert message</li></ul></li><li>2015-11-30 - Fixed auto spawn checkbox not working</li><li>2015-11-29 - Initial release</li></ul></div></div>');
  154. $('#infoPanel-footer').html('<a href="https://greasyfork.org/en/scripts/14297-agar-io-auto-respawn-evergreen" target="_blank">Homepage</a> - <a href="http://pastebin.com/raw.php?i=mkCsDgvd" target="_blank">Source Code</a> - <a href="#" onclick="$(\'#donate-mod input[name=submit]\').click(); return false;">Donate</a>');
  155. };
  156.  
  157. function applyConfig() {
  158. var checkbox = $('#options input[type="checkbox"]');
  159. localStorage.removeItem('settings');
  160. checkbox.change(function() { localStorage.setItem($(this).next().attr('data-itr'), $(this).prop('checked')); });
  161. checkbox.each(function() { $(this).prop('checked', false); if(localStorage.getItem($(this).next().attr('data-itr')) == 'true') { $(this).click(); } });
  162. $('#nick, #gamemode, #region, #quality').change(function() { localStorage.setItem($(this).attr('id'), $(this).val()) })
  163. $('#gamemode, #region, #quality').each(function() { if(localStorage.getItem($(this).attr('id')) != null) { $(this).val(localStorage.getItem($(this).attr('id'))).change(); } });
  164. }
  165.  
  166. function startGame() {
  167. if(overlayClosed) setNick($('#nick').val());
  168. }
  169. function randomMove() {
  170. var pos = {clientX: getRandomInt(0, innerWidth), clientY: getRandomInt(0, innerHeight)}
  171. canvas.onmousedown(pos);
  172. }
  173. function hookOverlay() {
  174. $('button[data-itr="play"]').click(function() { overlayClosed = true; });
  175. $('button[data-itr="play_as_guest"]').click(function() { overlayClosed = true; });
  176. $('button[data-itr="spectate"]').click(function() { overlayClosed = false; });
  177.  
  178. $.each(['show', 'hide'], function (i, ev) { var el = $.fn[ev]; $.fn[ev] = function () { this.trigger(ev); return el.apply(this, arguments); }; });
  179. $('#connecting').on('show', function() { connectingInfo(); });
  180. $('#connecting').on('hide', function() { if(spectatorMode) $('button[data-itr="spectate"]').click(); });
  181. $('#openfl-content').on('hide', function() { setTimeout(function() { $('#openfl-content').css({'opacity' : '1'}); }, 10); });
  182. }
  183. function showPanels(panel) {
  184. $('#openfl-content').css({'opacity' : '0.15'});
  185. if(panel == 1) $('#openShopBtn').click();
  186. else if(panel == 2) $('#skinButton').click();
  187. else if(panel == 3) $('#boostButton').click();
  188. else if(panel == 4) $('#massButton').click();
  189. else if(panel == 5) $('#freeCoins').click();
  190. }
  191.  
  192. function connectingInfo() { $('#connectingToInfo').text($('#region option:selected').text().split(' (')[0] + ' - ' + $('#gamemode option:selected').text().split(' (')[0]) }
  193.  
  194. function timeSince(date) {
  195. var seconds = Math.floor((new Date() - date) / 1000);
  196. var interval = Math.floor(seconds / 31536000);
  197. if(interval > 1) return interval + ' years'; interval = Math.floor(seconds / 2592000);
  198. if(interval > 1) return interval + ' months'; interval = Math.floor(seconds / 86400);
  199. if(interval > 1) return interval + ' days'; interval = Math.floor(seconds / 3600);
  200. if(interval > 1) return interval + ' hours'; interval = Math.floor(seconds / 60);
  201. if(interval > 1) return interval + ' minutes';
  202. return Math.floor(seconds) + ' seconds';
  203. }
  204.  
  205. function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement