Skip to content

Instantly share code, notes, and snippets.

@mat-1
Last active June 28, 2024 08:28
Show Gist options
  • Save mat-1/61c2bb5cc218b900ed89c62980a58e99 to your computer and use it in GitHub Desktop.
Save mat-1/61c2bb5cc218b900ed89c62980a58e99 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Photopea Premium
// @namespace http://tampermonkey.net/
// @version 2024-02-03
// @description Unlock Photopea Premium by patching their JS
// @author mat
// @match https://www.photopea.com/
// @match https://www.photopea.com/?utm_source=homescreen
// @icon https://www.google.com/s2/favicons?sz=64&domain=photopea.com
// @grant GM_webRequest
// @run-at document-start
// @downloadURL https://gist.githubusercontent.com/mat-1/61c2bb5cc218b900ed89c62980a58e99/raw/photopea-premium.js
// @updateURL https://gist.githubusercontent.com/mat-1/61c2bb5cc218b900ed89c62980a58e99/raw/photopea-premium.js
// @webRequest {"selector": "https://www.photopea.com/code/pp/pp.js", "action": "cancel"}
// ==/UserScript==
unsafeWindow.locStor = unsafeWindow.localStorage
// the service worker breaks our patching so we have to disable it :(
unsafeWindow.navigator.serviceWorker.register = async (..._) => {}
unsafeWindow.addEventListener('load', async () => {
GM_webRequest([
{ selector: 'https://www.photopea.com/code/pp/pp.js', action: '' },
]);
const js = await fetch('https://www.photopea.com/code/pp/pp.js').then(res => res.text())
const patchedJs = js.replace(/(?<=\w\w\.\w\w=function\(\)){(?=var \w=\w\w\.\w\w\(\);if\(\w==null\)return null;var )/g, '{return true;')
unsafeWindow.eval(patchedJs)
unsafeWindow.onload()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment