-
Create a fresh new Next js project. https://nextjs.org/docs/getting-started#automatic-setup
pnpm create next-app --typescript
-
install prettier
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
// Writen for a Chrome extension. It checks for a specific element on the page and calls a callback when it's found. | |
// Returns an element and all its child elements. | |
const getAllElements = (node: Node): Element[] => { | |
if (!(node instanceof Element)) { | |
return []; | |
} | |
const nodes = [node]; | |
if (node.childNodes) { | |
nodes.push(...[...node.childNodes].flatMap(getAllElements)); |