letsgo / ImageBrightnessGTARG

// ==UserScript==
// @name        ImageBrightnessGTARG
// @author      LetsGo
// @namespace   http://github.com/LetsGoGT/GTARG
// @version     1.0
// @description Allows user to manipulate image brightness in the Gametheory ARG 
// @match       https://www.thetheoristgateway.com/tenretniolleh/key.html
// @license     GPL-3.0-only
// ==/UserScript==

window.onload = () => {
  try{var c=document.getElementsByClassName('solved_key')[0x0].firstElementChild}catch(d){try{var c=document.getElementsByClassName('key-content')[0x0].firstElementChild}catch(f){console.log('No\x20element\x20found\x20with\x20classname\x20of\x20either\x20solved_key\x20or\x20key-content')}}if(c.tagName=='IMG'){g()}else{console.log('Key\x20content\x20does\x20not\x20contain\x20an\x20image,\x20but\x20instead\x20a\x20'+c.tagName)}function g(){var h=c.parentElement;var i=c.getAttribute('src');c.remove();var j=document.createElement('img');j.setAttribute('src',i);var k=document.createElement('canvas');k.setAttribute('id','canvas');h.appendChild(k);var l=k.getContext('2d');k.width=j.width;k.height=j.height;n(l,j);var m=q(l,j,0x64,'Brightness:\x20',0x1,0x3e8,'%','brightness');h.appendChild(m)}function n(o,p){o.drawImage(p,0x0,0x0,p.width,p.height)}function q(r,s,t,u,v,w,x,y,z=0x1){var A=document.createElement('div');var B=F(u);var C=F();var D=document.createElement('input');var E=document.createElement('button');E.onclick=function(){D.value=t;C.innerHTML='\x20\x20\x20\x20\x20\x20'+D.value+x;r.filter=y+'('+D.value+x+')';n(r,s)};E.innerHTML='Reset';D.setAttribute('type','range');D.setAttribute('min',v);D.setAttribute('max',w);D.step=z;D.value=t;C.innerHTML='\x20\x20\x20\x20\x20'+D.value+x;D.oninput=function(){C.innerHTML='\x20\x20\x20\x20\x20\x20'+D.value+x;r.filter=y+'('+D.value+x+')';n(r,s)};A.appendChild(B);A.appendChild(D);A.appendChild(C);A.appendChild(E);return A}function F(G=''){var H=document.createElement('span');H.setAttribute('style','font-family:\x20\x27Roboto\x27,\x20sans-serif');H.innerHTML=G;return H}
}