This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
/
overlay.js
41 lines (37 loc) · 2.05 KB
/
overlay.js
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
// ==UserScript==
// @name r/Place overlay for Vietnam
// @namespace http://tampermonkey.net/
// @version alpha two
// @description r/Place overlay for the Vietnam flag (1490,661 -> 1561,687). Stolen from OsuPlace.
// @author u/oralekin (OC), u/LittleEndu, u/ekgame, u/84436, t3bol90 (not on reddit yet)
// @match https://hot-potato.reddit.com/embed*
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant none
// ==/UserScript==
if (window.top !== window.self) {
window.addEventListener('load', () => {
// Load the image
const image = document.createElement("img");
// image.src = "https://cdn.mirai.gg/tmp/dotted-place-template.png";
image.src = "https://raw.githubusercontent.com/t3bol90/flag-of-vietnam-rplace2022/main/flag.png";
image.onload = () => {
image.style = `position: absolute; left: 0; top: 0; width: ${image.width/3}px; height: ${image.height/3}px; image-rendering: pixelated; z-index: 1`;
};
// Add the image as overlay
const camera = document.querySelector("mona-lisa-embed").shadowRoot.querySelector("mona-lisa-camera");
const canvas = camera.querySelector("mona-lisa-canvas");
canvas.shadowRoot.querySelector('.container').appendChild(image);
// Add a 50% white overlay
//canvas.shadowRoot.querySelector('.container canvas').style.opacity = "0.50";
// Add a style to put a hole in the pixel preview (to see the current or desired color)
const waitForPreview = setInterval(() => {
const preview = camera.querySelector("mona-lisa-pixel-preview");
if (preview) {
clearInterval(waitForPreview);
const style = document.createElement('style')
style.innerHTML = '.pixel { clip-path: polygon(-20% -20%, -20% 120%, 37% 120%, 37% 37%, 62% 37%, 62% 62%, 37% 62%, 37% 120%, 120% 120%, 120% -20%); }'
preview.shadowRoot.appendChild(style);
}
}, 100);
}, false);
}