Skip to content

Instantly share code, notes, and snippets.

View AyoAlfonso's full-sized avatar
:octocat:
Building

Ayo Alfonso AyoAlfonso

:octocat:
Building
View GitHub Profile
@AyoAlfonso
AyoAlfonso / text_nodes.js
Created October 30, 2022 14:48 — forked from mwunsch/text_nodes.js
Get the text nodes out of a document, ignoring the ones that are in Elements where the text value aren't likely to be valuable (like <script> tags) and nodes containing just whitespace.
function getLegitTextNodes() {
if (!document.createTreeWalker) return [];
var blacklist = ['SCRIPT', 'OPTION', 'TEXTAREA'],
textNodes = [],
walker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_TEXT,
function excludeBlacklistedNodes(node) {
if (blacklist.indexOf(node.parentElement.nodeName.toUpperCase()) >= 0) return NodeFilter.FILTER_REJECT;
@AyoAlfonso
AyoAlfonso / component.js
Created November 2, 2022 19:54 — forked from Chojiu15/component.js
index.js
import React, { useState, useEffect } from "react";
import axios from "axios";
const Test = () => {
const [data, setData] = useState([]);
const [land, setLand] = useState("");
const [pop, setPop] = useState({
country: "",
population: "",
year: "",
@AyoAlfonso
AyoAlfonso / vanilla-js-cheatsheet.md
Created November 2, 2022 22:16 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet