Skip to content

Instantly share code, notes, and snippets.

let downloaded = new Set();
let observer = new MutationObserver(arr => {
for (let mutationRecord of arr) {
for (let node of Array.from(mutationRecord.addedNodes)) {
let canvas = node.parentElement.getElementsByTagName("canvas")[0];
if (canvas && !downloaded.has(canvas.id)) {
downloaded.add(canvas.id);
saveCanvasAsPNG(canvas);
}
}
@AviKav
AviKav / recursiveAssign.js
Last active February 8, 2017 04:40
Recursive version of `Object.assign()`
function recursiveAssign(target, ...sources) {
for (let i of let objs = Object.keys(sources)) {
let obj = sources[objs[i]];
if ((typeof obj !== "object" || obj === null) && obj === sources[sources.length-1]) {
// If `sources[objs[i]]` is a a non `Object` built-in and the is (or is the same as) last element in `sources`, then there is no need to go any further. Also, `typeof null === "object"`
if (obj === sources[sources.length-1]) {
target = obj;
return;
}
} else {