Greasy Fork is available in English.

Paper.IO Enhanced

Zoom hack, game speed change hack, and instant movement hack.

  1. // ==UserScript==
  2. // @name Paper.IO Enhanced
  3. // @namespace -
  4. // @version 1.1.3
  5. // @description Zoom hack, game speed change hack, and instant movement hack.
  6. // @author NotYou
  7. // @match *://paper-io.com/*
  8. // @match *://*.paper-io.com/*
  9. // @run-at document-start
  10. // @license GPL-3.0-or-later
  11. // @grant none
  12. // @icon data:image/png;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAe8MAYnvDAHp7wwB6e8MAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHvDAMp7wwD/e8MA/3vDAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB7wwDKe8MA/3vDAP97wwBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfcQAyn3EAP99xAD/fcQAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIHGAMqBxgD/gcYA/4HGAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACHyQDKh8kA/4fJAP+HyQBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjcwAyo3MAP+NzAD/jcwAsI7MAJSOzACUhrgAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJPPAMqTzwD/k88A/5PPAP+TzwD/k88A/4q5DfqKtxdaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACb0wDKm9MA/5vTAP+b0wD/m9MA/5vTAP+Rvif/kLss+pG8MVoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAodYDyqHWA/+h1gP/oNYBhp/VAFyf1QBcnc4X7J3OGP+ezhf6oNMOIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKnaKMqp2ij/qdoo/6naKEAAAAAAAAAAAKnaKOKp2ij/qdoo/6naKCoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACv3UHKr91B/6/dQf+v3UFAAAAAAAAAAACv3UHir91B/6/dQf+v3UEqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAr9VclK/UX/+v1F//tN1WwrXgVK614FSur9Ve9q/UX/+v1F7gsdpUEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAK/QbASx0XCisdFx/7nfY/+64mD/uuJg/7LTb/+x0XDgsNBtIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtdN3ArbUeqK+4W//v+Rt/7/kbf+31nngtdN4IgAAAAAAAAAAAAAAALXTdwwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC614AEweR2QMLmdELC5nRCvNt8GgAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAPH/AADx/wAA8f8AAPH/AADx/wAA8D8AAPAfAADwDwAA8McAAPHHAADxxwAA8AcAAPgPAAD8HwAA//8AAA==
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. const MIN_ZOOM = 0.5
  17. const MAX_ZOOM = 3.5
  18.  
  19. const MIN_GAME_SPEED = 10
  20. const MAX_GAME_SPEED = 1000
  21.  
  22. const DEBUG_LEVEL = 0 /* 0 - disabled; 1 - info; 2 - errors */
  23. const API_PROPS = ['paperio2api', 'paper2']
  24.  
  25. class Utils {
  26. static minmax(n, min, max) {
  27. return Math.min(Math.max(n, min), max)
  28. }
  29.  
  30. static debug(level, ...args) {
  31. let _level
  32.  
  33. switch (level) {
  34. case 'log':
  35. _level = 0
  36. break
  37. case 'error':
  38. _level = 1
  39. break
  40. }
  41.  
  42. if(DEBUG_LEVEL > _level) {
  43. console[level].apply(this, args)
  44. }
  45. }
  46.  
  47. static waitForProperty(target, props) {
  48. let tries = 0
  49.  
  50. try {
  51. return new Promise((res, rej) => {
  52. let intervalId = setInterval(() => {
  53. tries++
  54.  
  55. let validProp = props.find(prop => target[prop])
  56.  
  57. if(validProp) {
  58. clearInterval(intervalId)
  59. return res(target[validProp])
  60. }
  61.  
  62. if(tries > 6) {
  63. rej('Timeout error, cannot find properties: "' + props + '" in target object.')
  64. }
  65. }, 1e3)
  66. })
  67. } catch(e) {
  68. Utils.debug('error', 'waitForProperty', e)
  69. }
  70. }
  71. }
  72.  
  73. class Hack {
  74. static init(paper_api) {
  75. const GAME = paper_api.game
  76. const CONFIG = GAME.config
  77. const SCENE = getScene()
  78.  
  79. Utils.debug('log', this.name + ' initialized!')
  80.  
  81. class GameSpeedHack {
  82. static init(maxGameSpeed, minGameSpeed) {
  83. window.addEventListener('wheel', e => {
  84. if(e.ctrlKey) {
  85. e.preventDefault()
  86.  
  87. const isPositive = e.deltaY > 0
  88.  
  89. CONFIG.unitSpeed += isPositive ? -2.5 : 2.5
  90.  
  91. const current = CONFIG.unitSpeed
  92.  
  93. CONFIG.unitSpeed = Utils.minmax(current, minGameSpeed, maxGameSpeed)
  94. }
  95. })
  96. }
  97. }
  98.  
  99. class ZoomHack {
  100. static init(maxZoom, minZoom) {
  101. window.addEventListener('wheel', e => {
  102. if(!e.ctrlKey) {
  103. const isPositive = e.deltaY > 0
  104.  
  105. SCENE.maxScale += isPositive ? -0.5 : 0.5
  106.  
  107. const current = SCENE.maxScale
  108.  
  109. SCENE.maxScale = Utils.minmax(current, minZoom, maxZoom)
  110. }
  111. })
  112. }
  113. }
  114.  
  115. class InstantMovement {
  116. static init(listenersData) {
  117. listenersData.forEach(data => {
  118.  
  119. try {
  120. window.addEventListener('keydown', e => {
  121. try {
  122. if(e.code === data.code) {
  123. const PLAYER = GAME.player
  124.  
  125. PLAYER.position[data.direction] += 10 * (data.isNegative ? -1 : 1)
  126. }
  127. } catch(err) {
  128. Utils.debug('error', data, err)
  129. }
  130. })
  131. } catch(e) {
  132. Utils.debug('error', this.name, data, e)
  133. }
  134. })
  135. }
  136. }
  137.  
  138. GameSpeedHack.init(
  139. MAX_GAME_SPEED,
  140. MIN_GAME_SPEED
  141. )
  142.  
  143. ZoomHack.init(
  144. MAX_ZOOM,
  145. MIN_ZOOM
  146. )
  147.  
  148. InstantMovement.init([{
  149. code: 'KeyW',
  150. direction: 'y',
  151. isNegative: true,
  152. }, {
  153. code: 'KeyS',
  154. direction: 'y',
  155. isNegative: false,
  156. }, {
  157. code: 'KeyA',
  158. direction: 'x',
  159. isNegative: true,
  160. }, {
  161. code: 'KeyD',
  162. direction: 'x',
  163. isNegative: false,
  164. }])
  165.  
  166. function getScene() {
  167. if(paper_api.currentConfig) {
  168. return paper_api.currentConfig
  169. }
  170.  
  171. if(paper_api.configs) {
  172. return paper_api.configs.paper2_classic
  173. }
  174.  
  175. return paper_api.config
  176. }
  177. }
  178. }
  179.  
  180.  
  181. class Main {
  182. static init() {
  183. Utils.waitForProperty(window, API_PROPS).then(paperapi => {
  184. Utils.waitForProperty(paperapi, ['game']).then(() => {
  185. Hack.init(paperapi)
  186. })
  187. })
  188. }
  189. }
  190.  
  191. Main.init()
  192. })()