Utoljára aktív 1756817812

Use as userscript

silver gist felülvizsgálása 1756817812. Revízióhoz ugrás

1 file changed, 45 insertions

photopea.js(fájl létrehozva)

@@ -0,0 +1,45 @@
1 + // ==UserScript==
2 + // @name photopea
3 + // @namespace http://tampermonkey.net/
4 + // @version 0.1
5 + // @author You
6 + // @match https://www.photopea.com/
7 + // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
8 + // @description photopea adblock
9 + // @grant none
10 + // @license MIT
11 + // ==/UserScript==
12 +
13 + (function () {
14 + "use strict";
15 +
16 + const style = document.createElement("style");
17 + style.textContent = ".app > div:not(:first-child) { visibility: hidden; }";
18 + document.head.appendChild(style);
19 + function addCustomEvent() {
20 + const ADS_WIDTH = 320;
21 + document.addEventListener("resizecanvas", (e) => {
22 + // push the ads container outside of the viewport
23 + window.innerWidth = document.documentElement.clientWidth + ADS_WIDTH;
24 + });
25 + }
26 + // inject our custom event listener into the "main world"
27 + document.documentElement.setAttribute("onreset", `(${addCustomEvent})()`);
28 + document.documentElement.dispatchEvent(new CustomEvent("reset"));
29 + document.documentElement.removeAttribute("onreset");
30 + function resize(event = {}) {
31 + if (!event.skip) {
32 + document.dispatchEvent(new CustomEvent("resizecanvas"));
33 + // trigger another resize event to update any listeners with the new window.innerWidth
34 + const resizeEvent = new Event("resize");
35 + resizeEvent.skip = true;
36 + window.dispatchEvent(resizeEvent);
37 + }
38 + }
39 + let debounce;
40 + window.addEventListener("resize", (event) => {
41 + clearTimeout(debounce);
42 + debounce = setTimeout(() => resize(event), 100);
43 + });
44 + resize();
45 + })();
Újabb Régebbi