-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjahrein.2023.user.js
44 lines (41 loc) · 1.99 KB
/
jahrein.2023.user.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
42
43
44
// ==UserScript==
// @name Jahrein RPlace 2023
// @namespace https://okunamayanad.com/
// @version 1.1
// @description Discord: @okunamayand, Github: https://github.com/okunamayanad/r-place-2023
// @author okunamayanad
// @match https://garlic-bread.reddit.com/embed*
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant none
// @license MIT
// @downloadURL https://github.com/okunamayanad/r-place-2023/raw/main/jahrein.2023.user.js
// @updateURL https://github.com/okunamayanad/r-place-2023/raw/main/jahrein.2023.user.js
// ==/UserScript==
console.log("1");
if (window.top !== window.self) {
console.log("2");
// console.log("3");
// Load the image
const image = document.createElement("img");
var d = new Date();
image.src = "https://r-place-2023.vercel.app/jahrein-output.png?" + d.getTime();
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("garlic-bread-embed").shadowRoot.querySelector("garlic-bread-camera");
const canvas = camera.querySelector("garlic-bread-canvas");
const container = canvas.shadowRoot.querySelector('.container')
container.appendChild(image);
console.log("container", container);
// 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("garlic-bread-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);
}