Skip to content

Instantly share code, notes, and snippets.

🔄
Life is good until it isn't

Joel Griffith joelgriffith

🔄
Life is good until it isn't
Block or report user

Report or block joelgriffith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lhr.json
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/70.0.3508.0 Safari/537.36",
"lighthouseVersion": "3.0.3",
"fetchTime": "2018-09-06T16:55:02.940Z",
"requestedUrl": "https://www.chromestatus.com/features",
"finalUrl": "https://www.chromestatus.com/features",
"runWarnings": [],
"audits": {
"is-on-https": {
"id": "is-on-https",
@joelgriffith
joelgriffith / big-screenshot.js
Created Feb 23, 2018
Large Puppeteer Images
View big-screenshot.js
const puppeteer = require('puppeteer');
const merge = require('merge-img');
const pageUrl = ''; // REPLACE ME
const pageElement = '#svgcanvas'; // REPLACE ME
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(pageUrl);
@joelgriffith
joelgriffith / browserless-unfurl.js
Last active Feb 12, 2018
Unfurls a link into semantic data
View browserless-unfurl.js
import puppeteer from 'puppeteer';
function getTitle() {
if (document.querySelector('meta[property="og:title"]')) {
return document.querySelector('meta[property="og:title"]').content;
}
if (document.querySelector('[itemprop="name"]')) {
return document.querySelector('[itemprop="name"]').text;
}
if (document.querySelector('title')) {
View get-image.js
async function getImage(page) {
if (document.querySelector('meta[property="og:image"]')) {
return document.querySelector('meta[property="og:image"]').content;
}
if (document.querySelector('[itemprop="image"]')) {
return document.querySelector('[itemprop="image"]').text;
}
// Return null so we can handle it later
return null;
}
View browserless-cnn-title.js
const puppeteer = require('puppeteer');
function getTitle() {
if (document.querySelector('meta[property="og:title"]')) {
return document.querySelector('meta[property="og:title"]').content;
}
if (document.querySelector('[itemprop="name"]')) {
return document.querySelector('[itemprop="name"]').text;
}
if (document.querySelector('title')) {
@joelgriffith
joelgriffith / description.js
Created Jan 15, 2018
Get's a site description
View description.js
function getDescription() {
if (document.querySelector('meta[property="og:description"]')) {
return document.querySelector('meta[property="og:description"]').content;
}
if (document.querySelector('[itemprop="description"]')) {
return document.querySelector('[itemprop="description"]').text;
}
if (document.querySelector('meta[name="description"]')) {
@joelgriffith
joelgriffith / title.js
Last active Jan 15, 2018
Find website titles (title, OpenGraph, schema.org)
View title.js
function getTitle() {
if (document.querySelector('meta[property="og:title"]')) {
return document.querySelector('meta[property="og:title"]').content;
}
if (document.querySelector('[itemprop="name"]')) {
return document.querySelector('[itemprop="name"]').text;
}
if (document.querySelector('title')) {
@joelgriffith
joelgriffith / headless-libraries.js
Last active Sep 20, 2017
Compares headless libraries
View headless-libraries.js
// Puppeteer
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'example.png'});
await browser.close();
View evaluat.js
const { Chrome } = require('navalia');
const chrome = new Chrome();
chrome
.goto('https://www.google.com/', { pageload: false })
.evaluate(() => 'INSERT YOUR SCRIPT HERE')
// More stuff
.then((results) => {
console.log(results);
@joelgriffith
joelgriffith / jest-image-snapshot-setup.js
Created Jul 20, 2017
Setting up jest-image-snapshot
View jest-image-snapshot-setup.js
import { toMatchImageSnapshot } from 'jest-image-snapshot';
expect.extend({ toMatchImageSnapshot });
You can’t perform that action at this time.