Paper.IO Enhanced

Zoom cheat, game speed change cheat

As of 2023-01-10. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name Paper.IO Enhanced
// @namespace -
// @version 1.0.0
// @description Zoom cheat, game speed change cheat
// @author NotYou
// @match *://paper-io.com*
// @match *://www.paper-io.com*
// @run-at document-start
// @license GPL-3.0-or-later
// @grant none
// @icon data:image/png;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAe8MAYnvDAHp7wwB6e8MAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHvDAMp7wwD/e8MA/3vDAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB7wwDKe8MA/3vDAP97wwBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfcQAyn3EAP99xAD/fcQAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIHGAMqBxgD/gcYA/4HGAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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ameSpeed = 10
    let maximalGameSpeed = 200

    // Do NOT edit code below

    let css = `
    #get_random_name {
      width: 60px;
      height: 60px;
      left: -70px;
      background: rgb(255, 255, 255);
      position: absolute;
      box-shadow: rgb(151, 151, 151) 0 6px 0;
      background-image: url(https://cdn-icons-png.flaticon.com/512/1714/1714041.png);
      background-size: 70% 70%;
      background-repeat: no-repeat;
      background-position: 50% 50%;
      filter: grayscale(1);
    }

    #get_random_name:active {
      box-shadow: none;
      top: 6px;
    }`

    class CookieControl {
        getEntries() {
            return document.cookie.replace(/\s/g, '').split(';').map(e => e.split('='))
        }

        set(name, value) {
            document.cookie = encodeURIComponent(name.trim()) + '=' + encodeURIComponent(value.trim())
        }

        get(name) {
            let entries = this.getEntries()

            return entries.find(e => e[0] === name)[1]
        }
    }

    let cookies = CookieControl.prototype

    waitForProperty(window, 'paper2').then(() => {
        let paper = window.paper2

        waitForProperty(paper, 'game').then(() => {
            let config = paper.game.config
            let scene = paper.configs.paper2_classic
            let game = paper.game

            // Get Random Name

            let username = document.querySelector('.username')

            username.insertAdjacentHTML('beforebegin', '<div id="get_random_name"></div>')

            document.querySelector('#get_random_name').addEventListener('click', () => {
                let name = getRandomName()

                username.querySelector('input').value = name
                cookies.set('paperio_username', name)
            })

            window.addEventListener('wheel', e => {
                let isPositive = e.deltaY > 0

                if(e.ctrlKey) {
                    e.preventDefault()

                    // Game Speed Cheat

                    config.unitSpeed += isPositive ? -2.5 : 2.5

                    let current = config.unitSpeed

                    config.unitSpeed = correctValue(current, minimalGameSpeed, maximalGameSpeed)
                } else {

                    // Zoom Cheat

                    scene.maxScale += isPositive ? -0.5 : 0.5

                    let current = scene.maxScale

                    scene.maxScale = correctValue(current, minimalZoom, maximalZoom)
                }
            })

            // Movement Cheat

            let listenersData = ['w', 'a', 's', 'd']

            listenersData.forEach((e, i) => {
                addKeyListener(e, i > 1 ? false : true, i % 2 === 0 ? 'y' : 'x')
            })

            // Nerd Stuff

            let styleNode = document.createElement('style')
            styleNode.appendChild(document.createTextNode(css))
            document.head.appendChild(styleNode)

            function addKeyListener(key, isNegative, coordinate) {
                let code = 'Key' + key.toUpperCase()
                let randomValue = Math.floor(Math.random() * 18)

                window.addEventListener('keydown', e => {
                    if(e.code === code) {
                        let player = game.player

                        if(player) {
                            player.position[coordinate] += randomValue * (isNegative ? -1 : 1)
                        }
                    }
                })
            }

            function getRandomName() {
                let namesPool = game.nameManager.pool

                return namesPool[Math.floor(Math.random() * namesPool.length)]
            }

            function correctValue(currentValue, minimalValue, maximalValue) {
                return Math.max(minimalValue, Math.min(maximalValue, currentValue))
            }
        })
    })

    function waitForProperty(target, prop) {
        return new Promise(res => {
            let interval = setInterval(() => {
                if(target[prop]) {
                    clearInterval(interval)
                    return res(target[prop])
                }
            }, 1e3)
        })
    }
})()