This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:((h,s)=>{(loop=()=>{requestAnimationFrame(loop),s.filter=`hue-rotate(${h=(h+10)%360}deg)`})()})(0,document.all[0].style); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Konami | |
* | |
* Listens for the [Konami code][1], runs a callback when detected. | |
* | |
* [1]: https://en.wikipedia.org/wiki/Konami_Code | |
* | |
* Example usage: | |
* | |
* import { konami } from './konami.js/'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BinaryText { | |
static encode(string) { | |
return string.split('').map(char => { | |
const charCode = char.charCodeAt(0); | |
return charCode.toString(2); | |
}).join(''); | |
} | |
static decode(binary) { | |
return binary.match(/.{8}/g).map(byte => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* RomanNumerals singleton class. | |
* | |
* Usage: | |
* | |
* RomanNumerals.convert(12); // 'XII' | |
*/ | |
class RomanNumerals { | |
static numeralValues = { | |
M: 1000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateFormat { | |
constructor(format) { | |
this.format = format instanceof String ? format : String(format); | |
} | |
get _formatMap() { | |
return ['yyyy', 'yy', 'mm', 'm', 'dd', 'd', 'hh', 'h', 'ii', 'i', 'ss', 's']; | |
} | |
format(date) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utility function parse a string as HTML, SVG or XML. | |
* | |
* Example usage: | |
* parse('<a href="https://www.google.com">')[0].click(); | |
* | |
* @param {string} string The string to parse [1] | |
* @param {type='text/html'} string The mime type to parse the string as [2] | |
* @returns {HTMLCollection} A HTML collection of the parsed elements | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert kebab-case to camelCase. | |
* @param {string} kebabString The kebab-case string to convert. | |
* @return {string} The string converted to camelCase. | |
*/ | |
function camelCase(kebabString) { | |
const div = document.createElement('div'); | |
div.setAttribute(`data-${kebabString}`, ''); | |
return Object.keys(div.dataset)[0]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Create a new bookmark – usually by right-clicking the bookmark toolbar. | |
// 2. Name it (e.g. ‘crosshair’) and paste the following line in the URL field: | |
javascript:((d,p)=>{c=d.body.appendChild(d.createElement('canvas')),a=c.getContext('2d'),d.onmousemove=(e)=>{c.width=w=innerWidth;c.height=h=innerHeight;with(c.style)position='absolute',top=left=0,width=w+p,height=h+p,pointerEvents='none';with(a)clearRect(0,0,w,h),fillStyle='#0002',fillRect(0,e.pageY,w,1),fillRect(e.pageX,0,1,h)}})(document, 'px') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The target language. [Browser support is good][1] but "en-US" is a safe default. | |
* | |
* [1]: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language | |
* | |
* @type {string} | |
*/ | |
const { language = "en-US" } = navigator; | |
/** |
OlderNewer