Skip to content

Instantly share code, notes, and snippets.

View wlib's full-sized avatar
🔙
delete all code

Daniel Ethridge wlib

🔙
delete all code
View GitHub Profile
const data = [...document.querySelectorAll("#scoreTable > tbody tr")]
.filter(a => a.cells.length > 1)
.map(a => {
const score = a.cells[10].innerText
const [earned, possible] = score.split("/").map(n => parseFloat(n))
return {
category: a.cells[1].innerText,
earned, possible
}
})
@wlib
wlib / jsconsole.js
Last active March 31, 2019 20:58
Ultra simple js console for when devtools are blocked
window.jsConsoleState = {
lines: ["This is a JavaScript console.\nTo clear history, run clear()\nTo exit, run exit()"],
isLooping: true
}
const jsConsole = () => {
// Show the previous lines above the prompt
const input = prompt(window.jsConsoleState.lines.join("\n"))
// Push user input for next prompt
window.jsConsoleState.lines.push(input)
{
"politics": [
{
"title": "Heligoland–Zanzibar Treaty\n",
"image": "https://histography.io/images/2562.jpg",
"link": "https://en.wikipedia.org/wiki/Heligoland–Zanzibar_Treaty"
},
{
"title": "Treaty of Madrid \n",
"image": "https://histography.io/images/2563.jpeg",
@wlib
wlib / task.js
Last active March 8, 2019 21:23
Super simple Task implementation. Lazy evaluation of anything sequentially.
const Task = run => ({
// (a -> e) -> (a -> r) -> Task(a) // Might be inaccurate idk
run,
// undefined -> undefined
log: () =>
run(console.error)
(console.log),
// (a -> b) -> Task(b)
@wlib
wlib / curry.js
Last active December 10, 2018 18:29
curry a js function
function _isPlaceholder(a) {
return a != null &&
typeof a === 'object' &&
a['@@functional/placeholder'] === true;
}
function _arity(n, fn) {
/* eslint-disable no-unused-vars */
switch (n) {
case 0: return function() { return fn.apply(this, arguments); };
javascript:fetch(`https://create.kahoot.it/rest/kahoots/${prompt("Paste the Kahoot ID")}/card/?includeKahoot=true`).then(res=>res.json()).then(json=>json.kahoot.questions.map((q,number)=>{const{choices}=q;for(let i=0;i<choices.length;i+=1){if(choices[i].correct){switch(i){case 0:return `Q${number+1}: red triangle - ${choices[i].answer }`;break;case 1:return `Q${number+1}: blue diamond - ${choices[i].answer }`;break;case 2:return `Q${number+1}: yellow circle - ${choices[i].answer }`;break;case 3:return `Q${number+1}: green square - ${choices[i].answer }`;break}}}}).join("\n")).then(answers=>open().document.body.innerText=answers);
function getWidgetURL(options) {
const url = new URL("https://s.tradingview.com/widgetembed/");
const defaultOptions = {
symbol: "BTCUSD",
interval: 60,
hidesidetoolbar: 0,
symboledit: 1,
saveimage: 1,
toolbarbg: "f1f3f6",
theme: "Light",
<html>
<head>
<title>Close Me</title>
</head>
<body>
<script>
const symbols = location.search.slice(1).split(",");
symbols.forEach(symbol => open(`https://s.tradingview.com/widgetembed/?symbol=${symbol}&interval=60&hidesidetoolbar=0&symboledit=1&saveimage=1&toolbarbg=f1f3f6&theme=Light&style=1&timezone=America%2FNew_York&locale=en`));
</script>
<html>
<head>
<title>Close Me</title>
</head>
<body>
<script>
const symbols = location.search.slice(1).split(",");
symbols.forEach(symbol => {
const w = open(`https://s.tradingview.com/widgetembed/?symbol=${symbol}&interval=60&hidesidetoolbar=0&symboledit=1&saveimage=1&toolbarbg=f1f3f6&theme=Light&style=1&timezone=America%2FNew_York&locale=en`);
<embed
id="player"
name="flash_object_embed"
src=""
width="100%" height="100%"
type="application/x-shockwave-flash"
allowscriptaccess="always"
align="middle"
allownetworking="internal"
wmode="direct"