Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Utility functions for injecting into webpages to do scraping and fun things.
// Use with no jQuery (sometimes there are SSL problems)
window.q = document.querySelectorAll.bind(document);
window.qq = document.querySelector.bind(document); = function(func, debug) {
// A very useful function for reading and modifying a bunch of nodes on a web page.
// example usage: q('a').map(node => node.getAttribute('href')) -> ['', 'closed-source/dictionaryofnumbers/', ...]
if (!func) { func = function(node) { return node;} }
var nodes = this;
var values = [];
for (var i=0; i < nodes.length; ++i) {
if (debug) {
// add a node and value so better inspection can happen
values.push([nodes[i], func(nodes[i])]);
} else {
if (debug) {
return values;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.