UNPKG

1.35 kBJavaScriptView Raw
1// quick/dirty script to scrape the emoji data and write them to JSON files for consumption elsewhere.
2// props to hassankhan for doing the work of converting these to data uris.
3var request = require('request'),
4 async = require('async'),
5 fs = require('fs');
6
7var urls = [
8 'https://raw.github.com/hassankhan/emojify.js/master/less/emojify.emoticons.less',
9 'https://raw.github.com/hassankhan/emojify.js/master/less/emojify.nature.less',
10 'https://raw.github.com/hassankhan/emojify.js/master/less/emojify.objects.less',
11 'https://raw.github.com/hassankhan/emojify.js/master/less/emojify.people.less',
12 'https://raw.github.com/hassankhan/emojify.js/master/less/emojify.places.less',
13 'https://raw.github.com/hassankhan/emojify.js/master/less/emojify.symbols.less'
14];
15
16async.each(urls, function (url, loopCb) {
17 var results = {};
18 request.get(url, function (err, res, body) {
19 var split = body.split('\n');
20 split.forEach(function (text) {
21 if (!text) return;
22 var text = String(text).slice(9),
23 name = text.match(/^\S+/)[0];
24
25 text = text.match(/url\((\S+)\)/)[0];
26 results[name] = text.slice(4, -1);
27 });
28 fs.writeFileSync('json/' + url.slice(65, -5) + '.json', JSON.stringify(results, null, 2));
29 loopCb();
30 });
31});