Skip to content

Instantly share code, notes, and snippets.

@korewaChino
Last active April 3, 2022 08:46
Show Gist options
  • Select an option

  • Save korewaChino/a4c1bd446b09f509c39b572d305950b3 to your computer and use it in GitHub Desktop.

Select an option

Save korewaChino/a4c1bd446b09f509c39b572d305950b3 to your computer and use it in GitHub Desktop.

Revisions

  1. korewaChino renamed this gist Apr 3, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. korewaChino revised this gist Apr 3, 2022. No changes.
  3. korewaChino created this gist Apr 3, 2022.
    36 changes: 36 additions & 0 deletions userscript.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    // ==UserScript==
    // @name osu! Logo template
    // @namespace http://tampermonkey.net/
    // @version 0.3
    // @description try to take over the canvas!
    // @author oralekin, LittleEndu, ekgame
    // @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.discordapp.com/attachments/959668720463122463/960095335932391494/image.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 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);
    }