Skip to content

Instantly share code, notes, and snippets.

@clarkb7
Last active July 21, 2023 01:47
Show Gist options
  • Save clarkb7/c46df01550e37bee1cc1bb4591ab9431 to your computer and use it in GitHub Desktop.
Save clarkb7/c46df01550e37bee1cc1bb4591ab9431 to your computer and use it in GitHub Desktop.
r/place 2023 puck overlay
// ==UserScript==
// @name PUCK template 2023
// @namespace http://tampermonkey.net/
// @version 0.3
// @description try to take over the canvas!
// @author Ruukas, clark, Rhys, huspaherzu, ???
// @match https://garlic-bread.reddit.com/embed*
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant none
// ==/UserScript==
let overlay = null;
if (window.top !== window.self) {
window.addEventListener('load', () => {
const shadowRoot = document.getElementsByTagName("garlic-bread-embed")[0].shadowRoot.children[0];
function toggle(){
const parent = shadowRoot.getElementsByTagName("garlic-bread-canvas")[0].shadowRoot.children[0];
if(overlay === null){
overlay = parent.appendChild((
function () {
const i = document.createElement("img");
i.src = "https://i.imgur.com/0LvHYLX.png";
i.style = "position: absolute;left: 0;top: 0;image-rendering: pixelated;width: 1000px;height: 1000px;";
console.log(i);
return i;
}
)());
}
else{
parent.removeChild(overlay);
overlay = null;
}
}
toggle();
shadowRoot.appendChild((
function () {
const button = document.createElement("button");
button.innerText = "Toggle overlay";
button.onclick = toggle;
button.style = "position: absolute;left: 5px;top: 100px;";
console.log(button);
return button;
}
)());
}, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment