Skip to content

Instantly share code, notes, and snippets.

View AutoSponge's full-sized avatar

Paul Grenier AutoSponge

View GitHub Profile
@AutoSponge
AutoSponge / curve.svg
Last active November 24, 2023 18:11
curve
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AutoSponge
AutoSponge / stream-x.js
Last active May 1, 2020 15:13
streaming custom element
class TextDecoderStream extends TransformStream {
constructor(encoding = 'utf8') {
super({
start() {
this.decoder = new TextDecoder(encoding);
},
transform(chunk, controller) {
controller.enqueue(this.decoder.decode(chunk, { stream: true }));
},
});
@AutoSponge
AutoSponge / shadow-walk-ax.js
Last active April 29, 2020 16:13
shadow heading check
// start scriptwriter (see https://scriptwriter.dev)
function* walkAxTree(node, filter) {
if (filter(node)) {
yield node;
}
const children = node.children || [];
for (const child of children) {
yield* walkAxTree(child, filter);
}
}
@AutoSponge
AutoSponge / index.html
Last active June 9, 2022 12:59
light dom render custom element
<!DOCTYPE html>
<html lang="en">
<head>
<title>Minimal Custom Elements (light &amp; shadow)!</title>
<!-- Import the webpage's stylesheet -->
<link rel="stylesheet" href="/style.css" />
<!-- Import the webpage's javascript file -->
<script src="/script.js" defer></script>
@AutoSponge
AutoSponge / _axe.md
Last active March 31, 2020 10:53
axe-core custom command for scriptwriter and accompanying Code Tour file.

Axe Custom Command for Scriptwriter

  • install playwright npm i -g playwright.
  • install scriptwriter npm i -g scriptwriter.
  • create a folder to run scriptwriter from and to load and save files.
  • install axe-core npm -i axe-core. You can load the axe-core.command.json file to show you how to build your own commands.
  • start scriptwriter scriptwriter. You can load into -b firefox or -b webkit.
  • copy the axe.command.js file to your folder and .load axe.command or paste it right into the repl.
  • next, navigate to a site using page.goto or if you used scriptwriter --no-headless you can browse.
@AutoSponge
AutoSponge / dupe-dom-ids.js
Last active March 30, 2020 15:41
finds duplicate dom ids
Array.from(document.querySelectorAll('[id]')).reduce((cache, el) => {
const els = cache[el.id] || [];
cache[el.id] = els.concat(el);
return cache;
}, {})
@AutoSponge
AutoSponge / .betterer.ts
Created March 21, 2020 15:41
betterer-test
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 March 21, 2020 03:10
list headings
$$('h1,h2,h3,h4,h5,h6,[role="heading"][aria-level]').map(el => [
`${el.tagName.replace(/\D/, '')}${el.getAttribute('aria-level') || ''}`,
el.textContent.trim(),
]);
Math.floor(Math.random() * 16777215).toString(16)