View README.md
View imgToDummyImage.js
var image = Array.from(document.querySelectorAll('img'));
image.map((ele,i) => {
var {width, height} = getComputedStyle(ele);
var newSrc = `http://dummyimage.com/${parseInt(width)}x${parseInt(height)}`;
if ('src' in ele) {
ele.setAttribute('src', newSrc)
} else {
var url = ele.style.backgroundImage;
console.log(url)
if (url) {
View SVGPathMinipulation.js
var path = document.querySelector("path");
function getPathCommands(pathElement) {
var data = pathElement.getAttribute("d");
var ofs = 0;
var indexes = data.match(/[hvmlcqtsaz]/gi).map(function(cmd, i) {
ofs += data.substr(ofs).indexOf(cmd) + 1;
return ofs - 1;
});
var commands = [];
indexes.map(function(curr, i) {
View lorem.console.js
var lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod neque eaque fuga culpa doloribus adipisci vel explicabo! Nihil ipsa commodi quae voluptates laudantium fugit nam. Itaque veniam iure aliquid harum!'
Array.from(document.querySelectorAll("a,h1,h2,h3,h4,h5,h6")).map((ele, i) => {
var img = ele.querySelector('img');
var span = ele.querySelector('span');
if (img) {
var info = getComputedStyle(img);
img.src = 'http://dummyimage.com/'+parseInt(info.width)+'x'+parseInt(info.height)
} else {
if (span) {
span.innerText = lorem.substr(0, span.innerText.length)
View SKETCH_basicGraphUserPlugin.js
var sketch = context.api();
var document = sketch.selectedDocument;
var selection = document.selectedLayers;
var page = document.selectedPage;
var values = sketch.getStringFromUser("Enter values", "10,30,10,22,50,10,30");
var canvasWidth = parseFloat(sketch.getStringFromUser("Canvas width", "300"));
var canvasHeight = parseFloat(sketch.getStringFromUser("Canvas height", "300"));
var graphValues = values.split(",");
var min = 1000000, max = -100000, width = canvasWidth / graphValues.length;
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)