Skip to content

Instantly share code, notes, and snippets.

@yuanqing
Last active October 10, 2016 16:18
Show Gist options
  • Save yuanqing/eef5358928ce842eb70f374628b02240 to your computer and use it in GitHub Desktop.
Save yuanqing/eef5358928ce842eb70f374628b02240 to your computer and use it in GitHub Desktop.

Results

URL font-family
http://google.co.jp arial, sans-serif
http://yahoo.co.jp "MS PGothic", Arial, "Hiragino Kaku Gothic ProN", Osaka, sans-serif
http://amazon.co.jp Arial, sans-serif
http://livedoor.jp "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "Meiryo UI", メイリオ, Meiryo, "MS Pゴシック", Arial, sans-serif
http://rakuten.co.jp Meiryo, "Hiragino Kaku Gothic ProN", "MS PGothic", sans-serif
http://ameblo.jp "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", メイリオ, Meiryo, "MS Pゴシック", "MS PGothic", sans-serif
http://naver.jp arial, sans-serif
http://nicovideo.jp "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", メイリオ, Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif
http://dmm.co.jp "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ Pro W3", メイリオ, Meiryo, "MS Pゴシック", sans-serif
http://goo.ne.jp Meiryo, "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "MS Pゴシック", Arial, sans-serif
http://blogspot.jp arial, sans-serif
http://blog.jp "Hiragino Kaku Gothic Pro", Meiryo, "MS PGothic", arial, sans-serif
http://hatena.ne.jp Arial, Helvetica, sans-serif
http://weblio.jp "MS Pゴシック", arial, sans-serif
http://sakura.ne.jp Verdana, "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN", Helvetica, "MS Pゴシック", sans-serif
http://impress.co.jp "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, メイリオ, Meiryo, "MS Pゴシック", "MS P Gothic", sans-serif
http://japanpost.jp メイリオ, Meiryo, "Meiryo UI", "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "MS Pゴシック", "MS PGothic", Helvetica, Arial, sans-serif
http://nikkeibp.co.jp メイリオ, "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", "MS Pゴシック", Helvetica, Arial, sans-serif
http://ameba.jp "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", メイリオ, Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif
http://so-net.ne.jp メイリオ, meiryo, "MS Pゴシック", "MS PGothic", Verdana, Arial, "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, sans-serif
http://mynavi.jp "Lucida Grande", "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", Meiryo, メイリオ, sans-serif
http://excite.co.jp Meiryo, "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN", Helvetica, Arial, sans-serif
http://biglobe.ne.jp "MS PGothic", Osaka, Arial, sans-serif
http://alc.co.jp "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, メイリオ, Meiryo, "MS Pゴシック", "MS PGothic", sans-serif
const alexaTopSites = require('alexa-top-sites');
let count = 0;
alexaTopSites.getPages(alexaTopSites.byCountry, 'JP', 10)
.then((result) => {
result.forEach((url) => {
if (url.endsWith('.jp') && count < 30) {
count++;
console.log(url);
}
});
})
.catch((error) => {
console.error(error);
process.exit(0);
});
process.stdout.on('error', (error) => {
if (err.code == 'EPIPE') {
process.exit(0);
}
});
const Table = require('cli-table2');
const Nightmare = require('nightmare');
const split = require('split');
const throat = require('throat')(2);
function parseFontStack(url) {
return new Nightmare({ show: false })
.goto(url)
.evaluate(() => {
var body = document.querySelector('body');
return window.getComputedStyle(body).fontFamily;
})
.end()
.then((fontFamily) => {
console.log(url, ': ', fontFamily);
return Promise.resolve({
url: url,
fontFamily: fontFamily
});
})
.catch((error) => {
console.error(error);
});
}
const promises = [];
process.stdin
.pipe(split())
.on('data', (url) => {
if (url) {
promises.push(throat(() => {
return parseFontStack(url);
}))
}
})
.on('end', () => {
Promise.all(promises).then((result) => {
const table = new Table({
colWidths: [30, 50],
head: ['URL', 'font-family'],
wordWrap: true
});
result.forEach((row) => {
table.push([row.url, row.fontFamily]);
});
console.log(table.toString());
});
});
{
"name": "font-stacks",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node alexa.js > urls && node font-stacks.js < urls",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Lim Yuan Qing",
"license": "MIT",
"dependencies": {
"alexa-top-sites": "1.1.0",
"cli-table2": "0.2.0",
"nightmare": "2.7.0",
"split": "1.0.0",
"throat": "3.0.0"
}
}
http://google.co.jp
http://yahoo.co.jp
http://amazon.co.jp
http://rakuten.co.jp
http://livedoor.jp
http://ameblo.jp
http://naver.jp
http://goo.ne.jp
http://nicovideo.jp
http://dmm.co.jp
http://hatena.ne.jp
http://blogspot.jp
http://blog.jp
http://weblio.jp
http://sakura.ne.jp
http://nikkeibp.co.jp
http://impress.co.jp
http://japanpost.jp
http://japanpost.jp
http://mynavi.jp
http://ameba.jp
http://so-net.ne.jp
http://biglobe.ne.jp
http://excite.co.jp
http://alc.co.jp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment