Skip to content

Instantly share code, notes, and snippets.

View adamhotep's full-sized avatar

Adam Katz adamhotep

View GitHub Profile
@adamhotep
adamhotep / DOM3D-1line.js
Last active March 27, 2024 16:34 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
(()=>{const SHOW_SIDES=false;const COLOR_SURFACE=false;const COLOR_RANDOM=false;const COLOR_HUE=190;const MAX_ROTATION=180;const THICKNESS=20;const DISTANCE=10000;function getRandomColor(){const hue=Math.floor(Math.random()*360);const saturation=50+Math.floor(Math.random()*30);const lightness=40+Math.floor(Math.random()*30);return`hsl(${hue},${saturation}%,${lightness}%)`;}const getDOMDepth=element=>[...element.children].reduce((max,child)=>Math.max(max,getDOMDepth(child)),0)+1;const domDepthCache=getDOMDepth(document.body);const getColorByDepth=(depth,hue=0,lighten=0)=>`hsl(${hue},75%,${Math.min(10+depth*(1+60/domDepthCache),90)+lighten}%)`;const body=document.body;body.style.overflow="visible";body.style.transformStyle="preserve-3d";body.style.perspective=DISTANCE;const perspectiveOriginX=(window.innerWidth/2);const perspectiveOriginY=(window.innerHeight/2);body.style.perspectiveOrigin=body.style.transformOrigin=`${perspectiveOriginX}px${perspectiveOriginY}px`;traverseDOM(body,0,0,0);document.addEventListen
@adamhotep
adamhotep / waitForKeyElements.js
Last active March 18, 2024 06:00 — forked from BrockA/waitForKeyElements.js
A utility function, for userscripts including Greasemonkey, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Original: https://gist.github.com/BrockA/2625891
Non-jQuery version by: Adam Katz,
https://gist.github.com/adamhotep/7c9068f2196326ab79145ae308b68f9e
License: CC BY-NC-SA 4.0 (*not* GPL-compatible)
changes made by Adam Katz (tracked by adamhotep's github gist) are
also licensed GPL v2+ (but note the CC BY-NC-SA prevents commercial use)
License via https://gist.github.com/BrockA/2625891#gistcomment-1617026
@adamhotep
adamhotep / conf.hexdump
Last active August 29, 2015 14:14 — forked from sygo/conf.hexdump
Generic Colouriser tweaks
# offset
regexp=^[0-9a-fA-F]{1,8}\b
colours=bold red
======
# Hex Bytes %_p
regexp=\|.+\|\s*$
colours=cyan
======
# Hex bytes
#regexp=([0-9a-fA-F]{1,2 })+