View flowText.js
function flowText(text, svg, width, style) {
svg.innerHTML = "";
width = width - style.padding.left;
var svgText = document.createElementNS("http://www.w3.org/2000/svg", "text");
var textNode = document.createTextNode("");
svgText.appendChild(textNode);
var testElement = svg.appendChild(svgText);
var words = text.split(" ");
View styleKeysSVG_chrome.js
var styleKeysSVG_chrome = [
"alignContent",
"alignItems",
"alignSelf",
"alignmentBaseline",
"all",
"animation",
"animationDelay",
"animationDirection",
"animationDuration",
View FB_syntheticEvents.js
// Works at: https://facebook.github.io/react/docs/events.html
var domNodes = document.querySelectorAll('blockquote:nth-of-type(2)~ul li a');
var documentation = {};
Array.prototype.map.call(domNodes, function(ele) {
var name = ele.getAttribute('href').replace(/\#/ig, '');
var group = [];
var groupName = ele.innerText.replace(' Events','');
var h3 = document.querySelector(`[name="${name}"]`).parentNode;
var events = h3.nextElementSibling.nextElementSibling.querySelector('.language-text').innerText;
View ChromeGetInfoAboutDimensionsjs
var CSSSelector = window.localStorage.getItem('CSSSelector');
CSSSelector = prompt('Enter a selector', (window.localStorage.getItem('CSSSelector').toString()!=='null') ? CSSSelector : 'body');
window.localStorage.setItem('CSSSelector', CSSSelector);
var elements = document.querySelectorAll(CSSSelector);
var q = '`';
var report = `Selector: ${q}${CSSSelector}${(elements.length>1) ? ' (FOUND '+elements.length+' OCCURANCES)' : ''}${q}\n------------\n`;
if (elements.length>0) {
var element = elements[0];
var computedRules = window.getComputedStyle(element);
report+=`${q}${q}${q}\npadding: ${computedRules['padding']}\nmargin: ${computedRules['margin']}\nwidth:${computedRules['width']}\nheight:${computedRules['height']}\nbox-sizing:${computedRules['box-sizing']}\n${q}${q}${q}\n`;
View ChromeGetDefinedRulesjs
var computedRules = window.getComputedStyle(document.body);
var md = '| Rule | Value |\n';
md+='|---------|---:|\n';
Array.from(computedRules).sort().map(function cssRule(rule) {
md+=`| ${rule.replace(/-/g,'\-')} | ${computedRules[rule].replace(/-/g,'\-')} |\n`;
});
copy(md)
View ChromeGetUsedClassesAsCSS.js
var allClasses = {}, css = '';
var startFrom = prompt('Where should I start?', '#application');
Array.prototype.forEach.call(document.querySelectorAll(startFrom+' *[class]'), function(element) {
Array.prototype.forEach.call(element.classList, function(className) {
if (!allClasses[className]) {
allClasses[className] = 0;
}
allClasses[className]++;
})
});
View JSONselect.js
// obj: JSON object
// selector: The path to the data you want to extract
function JSONselect(obj, selector) {
var levels = selector.split('.')
var object = obj;
levels.map(function(path) {
console.log(path)
object = object[path];
})
return object;
View cleanReactHTML.js
function cleanReactHTML(html) {
var result = html.replace(/data-reactid="[\.\d:\D]{1,23}"/g,'');
result = result.replace(/data-reactroot="[\.\d:\D]{1,23}"/g,'');
result = result.replace(/<!--[\s\S]*?-->/g,'');
return result
}
copy(cleanReactHTML(document.querySelector('.app').innerHTML));
View waitFor.js
function waitFor(ms, cb) {
var waitTill = new Date(new Date().getTime() + ms);
while(waitTill > new Date()){};
if (cb) {
cb()
} else {
return true
}
}
View readme.md

The world in SVG

Found on a pen by Magnus Kjelland on codepen