-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathinvertselection.min.js
1 lines (1 loc) · 1.79 KB
/
invertselection.min.js
1
javascript:krazete:(()=>{var a,h,m,v;function u(e){h.remove(),a.remove(),e.style.filter="invert(1)"==e.style.filter?"":"invert(1)"}function w(e){return e.touches?("touchmove"==e.type&&e.preventDefault(),e.touches[0]||e.changedTouches[0]):e}function p(e){window.removeEventListener("mousemove",y),window.removeEventListener("touchmove",y),window.removeEventListener("mouseup",p),window.removeEventListener("touchend",p),v=w(e);for(var e=u,t=Math.min(m.clientX,v.clientX),n=Math.max(m.clientX,v.clientX),i=Math.min(m.clientY,v.clientY),o=Math.max(m.clientY,v.clientY),l=Math.max(1,(n-t)/10),s=Math.max(1,(o-i)/10),d=[],c=t;c<=n;c+=l)for(var r=i;r<=o;r+=s)d.push(document.elementsFromPoint(c,r));d.sort((e,t)=>e.length-t.length),t=d[0].filter(t=>t!=h&&t!=a&&d.every(e=>e.includes(t))),console.log(t),e(t[0])}function y(e){e=w(e);h.style.left=Math.min(m.clientX,e.clientX)+"px",h.style.top=Math.min(m.clientY,e.clientY)+"px",h.style.width=Math.abs(e.clientX-m.clientX)+"px",h.style.height=Math.abs(e.clientY-m.clientY)+"px"}function t(e){window.removeEventListener("mousedown",t),window.removeEventListener("touchstart",t),window.addEventListener("mousemove",y),window.addEventListener("touchmove",y,{passive:!1}),window.addEventListener("mouseup",p),window.addEventListener("touchend",p),m=w(e),(h=document.createElement("div")).style.position="relative",h.style.left=m.clientX+"px",h.style.top=m.clientY+"px",h.style.width=0,h.style.height=0,h.style.outline="3px dashed black",h.style.boxShadow="inset 0 0 30px 3px white",h.style.mixBlendMode="difference",a.appendChild(h)}(a=document.createElement("div")).style.position="fixed",a.style.left=0,a.style.top=0,a.style.width="100%25",a.style.height="100%25",a.style.zIndex=1e13,document.body.appendChild(a),window.addEventListener("mousedown",t),window.addEventListener("touchstart",t)})();