Skip to content

Instantly share code, notes, and snippets.

@mat-1
Last active November 10, 2024 05:03
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://vecpea.com/code/pp/*", "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 () => {
const scriptEls = document.getElementsByTagName('script')
// find the script that looks like //vecpea.com/code/pp/pp1722375167.js
// at the time of writing it's always just the last script, but this may change
let mainScriptSrc;
for (const scriptEl of scriptEls) {
if (scriptEl.src.includes("/code/pp/")) {
mainScriptSrc = scriptEl.src
}
}
// unblock it
GM_webRequest([
{ selector: 'https://vecpea.com/code/pp/*', action: '' },
]);
const js = await fetch(mainScriptSrc).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()
})
@c1bles
Copy link

c1bles commented Nov 7, 2024

Note that this script is obsoleted by (and conflicts with) the built in "Unbreak" uBO filter. Still, I updated the script anyways.

what was the script about? free premium in photopea and vectorpea?

@mat-1
Copy link
Author

mat-1 commented Nov 7, 2024

Note that this script is obsoleted by (and conflicts with) the built in "Unbreak" uBO filter. Still, I updated the script anyways.

what was the script about? free premium in photopea and vectorpea?

I made it to remove the ad area that takes up a bunch of space, since uBlock Origin used to just hide the ad but leave the space blank there. It would also unlock any premium-only features if they existed, I'm not sure if they do though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment