// ==UserScript==
// @name Florr.io Shadows
// @namespace https://florr.io
// @version 1.0
// @description Adds some stylistic shadow effects to florr.io
// @author Jekyll#1005
// @match https://florr.io/*
// @run-at document-end
// @icon https://cdn.discordapp.com/avatars/433325944141512705/4fa453426eca8d2a552496519c2db741.webp
// ==/UserScript==
!function () { !function(){"use strict";let e=!1,t=0,n=null!=localStorage.getItem("Shader Menu Opened")&&JSON.parse(localStorage.getItem("Shader Menu Opened")),l=0;const o=(e,t,n)=>e+n*(t-e),s=document.createElement("div"),r={};function a(e,t,n,l){if(l&&!r.shadowOffscreenCanvas)return t;for(let t in r)e[t]=r[t];return r.shadowColorInherit&&(e.shadowColor=t),t}{const{set:e,get:t}=Object.getOwnPropertyDescriptor(CanvasRenderingContext2D.prototype,"fillStyle");Object.defineProperty(CanvasRenderingContext2D.prototype,"fillStyle",{get(){return t.call(this)},set(t){e.call(this,a(this,t,0,!1))}});const{set:n,get:l}=Object.getOwnPropertyDescriptor(CanvasRenderingContext2D.prototype,"strokeStyle");Object.defineProperty(CanvasRenderingContext2D.prototype,"strokeStyle",{get(){return l.call(this)},set(e){n.call(this,a(this,e,0,!1))}})}{const{set:e,get:t}=Object.getOwnPropertyDescriptor(OffscreenCanvasRenderingContext2D.prototype,"fillStyle");Object.defineProperty(OffscreenCanvasRenderingContext2D.prototype,"fillStyle",{get(){return t.call(this)},set(t){e.call(this,a(this,t,0,!0))}});const{set:n,get:l}=Object.getOwnPropertyDescriptor(OffscreenCanvasRenderingContext2D.prototype,"strokeStyle");Object.defineProperty(OffscreenCanvasRenderingContext2D.prototype,"strokeStyle",{get(){return l.call(this)},set(e){n.call(this,a(this,e,0,!0))}})}const i=document.createElement("p");i.style.position="absolute",i.style.top="0%",i.style.left="50%",i.style.fontFamily="Ubuntu",i.style.fontSize="3vw",i.innerText="Press F2 to open the Shadow Menu",i.style.color="#FFFFFF",i.style.transform="translate(-50%, -50%)",i.style.pointerEvents="none",document.body.appendChild(i),s.style.position="absolute",s.style.backgroundColor="#1a1a1a",s.style.border="1.6vw ridge #333333",s.style.top="50%",s.style.left="50%",s.style.fontFamily="Ubuntu",s.style.transform="translate(-50%, -50%)",s.style.padding="0.5vw";const d=[["Shadow Offset X",0,"slider",[-20,20],"shadowOffsetX"],["Shadow Offset Y",0,"slider",[-20,20],"shadowOffsetY"],["Shadow Strength",0,"slider",[0,30],"shadowBlur"],["Shadow Color","#111111","color",[],"shadowColor"],["Shadow Inherits Color",!1,"checkbox",[],"shadowColorInherit"],["Shadow on GUI (Reload Required)",!1,"checkbox",[],"shadowOffscreenCanvas"]].map(e=>{e[1]=null!=localStorage.getItem(e[0])?localStorage.getItem(e[0]):e[1];const t=document.createElement("div");t.style.width="100%",t.style.height="4vw",t.style.fontSize="2vw",t.style.color="#ffffff";const n=document.createElement("p");n.style.margin="0px",n.style.padding="0px",n.style.display="inline",t.appendChild(n);let l=null;switch(e[2]){case"slider":{const o=document.createElement("input");o.style.verticalAlign="middle",o.style.width="40%",o.type="range",n.innerText=`${e[0]} (${e[1]})`,o.min=e[3][0],o.max=e[3][1],o.value=JSON.parse(e[1]),o.style.margin="0px",o.style.display="inline",o.style.marginLeft="1.5vw",o.style.float="right",o.style["-webkit-appearance"]="none",o.style.height="1vw",o.addEventListener("input",t=>{n.innerText=`${e[0]} (${t.target.value})`,localStorage.setItem(e[0],t.target.value)}),o.step=1,l=o,t.appendChild(o)}break;case"color":{const o=document.createElement("input");o.style.verticalAlign="middle",o.type="color",o.value=e[1],o.style.margin="0px",o.style.display="inline",o.style.marginLeft="1.5vw",o.style.float="right",o.style.width="40%",o.style.border="0px",l=o,n.innerText=`${e[0]}`,o.addEventListener("input",t=>{localStorage.setItem(e[0],t.target.value)}),t.appendChild(o)}break;case"checkbox":{const o=document.createElement("input");o.style.verticalAlign="middle",o.type="checkbox",n.innerText=`${e[0]}`,o.style.display="inline",o.style.float="right",o.checked=JSON.parse(e[1]),o.style.width="1.5vw",o.style.height="1.5vw",o.addEventListener("input",t=>{localStorage.setItem(e[0],t.target.checked),console.log(t.target.checked)}),l=o,t.appendChild(o)}}return s.appendChild(t),{getValue:()=>"on"===l.value?l.checked:l.value,property:e[4]}}),c=document.createElement("div");c.style.width="100%",c.style.height="1.5vw",c.style.fontSize="1vw",c.style.color="#ffffff",c.style.position="absolute",c.style.bottom="0px";const y=document.createElement("a");y.text="Script by Jekyll#1005, Enjoy!",y.title="Skara's Biolink",y.href="https://skara.glitch.me/",y.style.float="right",y.style.padding="0px",y.style.margin="0px",y.style.marginRight="1vw",c.appendChild(y),s.appendChild(c),document.body.appendChild(s);const p=()=>{t=o(t,e,.2),s.style.opacity=t,s.style.top=`${50*t|0}%`,l=o(l,!n,.2),i.style.opacity=l,s.style.pointerEvents=t>.8?"auto":"none";const a=Math.min(innerWidth,innerHeight)/1080;s.style.width=`${800*a}px`,s.style.height=`${500*a}px`,requestAnimationFrame(p);for(let e of d){let t=isNaN(e.getValue())?e.getValue():+e.getValue();r[e.property]=t}};p(),window.addEventListener("keydown",t=>{113===t.keyCode&&(t.preventDefault(),e=!e,localStorage.setItem("Shader Menu Opened",!0),n=!0)})}();}();