Skip to content

Instantly share code, notes, and snippets.

Paul Grenier AutoSponge

Block or report user

Report or block AutoSponge

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AutoSponge
AutoSponge / dupe-dom-ids.js
Last active Mar 30, 2020
finds duplicate dom ids
View dupe-dom-ids.js
Array.from(document.querySelectorAll('[id]')).reduce((cache, el) => {
const els = cache[el.id] || [];
cache[el.id] = els.concat(el);
return cache;
}, {})
View .betterer.ts
const got = require('got');
const cheerio = require('cheerio');
const natural = require('natural');
const sentenceTokenizer = new natural.SentenceTokenizer();
const wordTokenizer = new natural.WordTokenizer();
const automatedReadability = require('automated-readability');
const page = 'https://www.24a11y.com/2019/automating-inclusive-documentation/';
const { smaller } = require('@betterer/constraints');
module.exports = {
@AutoSponge
AutoSponge / headings.js
Last active Mar 21, 2020
list headings
View headings.js
$$('h1,h2,h3,h4,h5,h6,[role="heading"][aria-level]').map(el => [
`${el.tagName.replace(/\D/, '')}${el.getAttribute('aria-level') || ''}`,
el.textContent.trim(),
]);
View random-color.js
Math.floor(Math.random() * 16777215).toString(16)
View playwright-repl.js
// node --experimental-repl-await ./repl.js
const repl = require('repl');
const playwright = require('playwright');
const config = {
headless: false,
args: [
// https://tink.uk/playing-with-the-accessibility-object-model-aom/
'--enable-blink-features=AccessibilityObjectModel',
],
};
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello!</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
<script
View tabbable.js
function createWalker(el = document.body) {
const walker = document.createTreeWalker(
el,
NodeFilter.SHOW_ELEMENT,
{ acceptNode: node => {
if (node.tabIndex > -1) {
if (!isVisible(node)) {
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
View keybase.md

Keybase proof

I hereby claim:

  • I am autosponge on github.
  • I am autosponge (https://keybase.io/autosponge) on keybase.
  • I have a public key ASBMNb8DiTIPYIougr8ILfSo8NgNS9hjLGo0Z9N5ASoFFQo

To claim this, I am signing this object:

@AutoSponge
AutoSponge / idle.js
Last active Oct 23, 2018
idle until urgent
View idle.js
const IDLE = Symbol('IDLE')
const idle = fn => {
let result = IDLE
const resolve = requestIdleCallback(() => {
result = fn()
})
return () => {
if (result === IDLE) {
cancelIdleCallback(resolve)
result = fn()
@AutoSponge
AutoSponge / emitter.js
Last active Jun 17, 2018
event emitter
View emitter.js
class Emitter {
constructor (data) {
this.data = data
this.events = new Map()
}
on (name, fn) {
const fns = this.events.get(name) || new Set()
fns.add(fn)
this.events.set(name, fns)
You can’t perform that action at this time.