Repository navigation
Expand file tree
/
Copy pathphotopea.js
More file actions
46 lines (41 loc) · 1.56 KB
/
Copy pathphotopea.js
File metadata and controls
46 lines (41 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// ═══════════════════════════════════
// superlevels: Photopea No Ads
// Hides the ad column on photopea.com (the width fix lives in photopea-main.js)
// ═══════════════════════════════════
(() => {
const STYLE_ID = "sl-photopea";
const CSS = `
/* Second column of the app row is the ad panel */
.flexrow.app > div:nth-child(2) { display: none !important; }
html, body { overflow: hidden !important; }
`;
function inject() {
if (document.getElementById(STYLE_ID)) return;
const style = document.createElement("style");
style.id = STYLE_ID;
style.textContent = CSS;
(document.head || document.documentElement).appendChild(style);
}
function remove() {
const el = document.getElementById(STYLE_ID);
if (el) el.remove();
}
chrome.storage.local.get(["photopea_enabled"], (data) => {
if (data.photopea_enabled !== false) {
inject();
// Photopea rebuilds <head>; re-inject if our style gets dropped
document.addEventListener("DOMContentLoaded", inject);
const obs = new MutationObserver(() => {
if (!document.getElementById(STYLE_ID)) inject();
});
obs.observe(document.documentElement, { childList: true, subtree: true });
setTimeout(() => obs.disconnect(), 15000);
}
});
chrome.runtime.onMessage.addListener((msg) => {
if (msg.type === "photopea_toggle") {
if (msg.enabled) inject();
else remove();
}
});
})();