Skip to content

Instantly share code, notes, and snippets.

@ianfabs
Last active August 25, 2018 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianfabs/25d6655e92578cfb8c1ce91ff4ba0a22 to your computer and use it in GitHub Desktop.
Save ianfabs/25d6655e92578cfb8c1ce91ff4ba0a22 to your computer and use it in GitHub Desktop.
ESQuery, a lightweight alternative to jQuery for the modern ECMAScript developer. Or not... I guess
const d = window.document;
const qs = d.querySelector.bind(d);
Element.prototype.qs = Element.prototype.querySelector;
const qsa = d.querySelectorAll.bind(d);
Element.prototype.qsa = Element.prototype.querySelectorAll;
const f = window.fetch;
const newTab = uri => window.open(uri, "_target");
const redirect = uri => window.open(uri, "_self");
const ce = d.createElement.bind(d);
Element.prototype.ac = Element.prototype.appendChild;
const ctn = d.createTextNode.bind(d);
console.__proto__.beep = () => {
let context = new AudioContext();
o = context.createOscillator()
g = context.createGain()
o.connect(g)
o.type = 'sine';
g.connect(context.destination)
o.start(0)
g.gain.exponentialRampToValueAtTime(
10, context.currentTime
)
setTimeout(()=>{
o.stop();
}, 500);
};
document.cookie.__proto__.getItem = (key) => (`; ${document.cookie}`.split(`; ${key}=`)).pop().split(";").shift()[0];
document.cookie.__proto__.setItem = (key, val)=>document.cookie = `${key}=${val};`;
function sleep(ms) {return new Promise(resolve => setTimeout(resolve, ms));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment