Git Product home page Git Product logo

Comments (6)

iamcal avatar iamcal commented on June 1, 2024 1

merged in #80 - facebook and messenger images are now supported

from emoji-data.

Crissov avatar Crissov commented on June 1, 2024

Do you have the exact image address syntax to scrape, though?

{ http | https }://www.facebook.com/images/emoji.php/v{ version number ≤ 7 }/ {type: z Messenger | f Facebook | e Extended | u Unicode}{2-hexdigit checksum()}/{single-digit pixel ratio: 1}/{decimal pixel width/height: 16|18|20|24|28|30|32|64|128} /{lowercase hexadecimal Unicode position, mostly 1fxyz}.png

/**
 * Facebook emoji URL checksum 
 * @param string codepoints = "{single-digit pixel ratio}/"
 *                          + "{decimal pixel width/height}/"
 *                          + "{lowercase hexadecimal Unicode positions, separated by underscores}.png" 
 *                          = `\d/\d{2,3}/[a-f\d_]+\.png` (lax RX)
 *                          = `[12]/(16|18|20|24|28|30|32|64|128)/[a-f\d]{4,5}(_[a-f\d]{4,5})*\.png` (stricter RX)
 * @param int base = 317426846 (default)
 * @returns string of 2 hexadecimal digits
 */
    function checksum(codepoints, base) {
        codepoints = b.unescape(encodeURIComponent(codepoints)); /** `unescape()`: `&amp;` → `&`, `&lt;` → `<`, `&gt;` → `>`, `&quot;` → `"`, `&#x27;` → `'` */
        for (var pos = 0; pos < codepoints.length; pos++) {
            base = (base << 5) - base + codepoints.charCodeAt(pos);
            base &= 4294967295;
        }
        return (base & 255).toString(16);
    }

JFTR, snippets of JS code I’m getting served today (don’t know how stable/universal):

__d('EmojiImageURL', ['invariant', 'EmojiStaticConfig', 'EmojiConfig'], (function a(b, c, d, e, f, g, h) {
    function i(k, l) {
        k = b.unescape(encodeURIComponent(k));
        for (var m = 0; m < k.length; m++) {
            l = (l << 5) - l + k.charCodeAt(m);
            l &= 4294967295;
        }
        return (l & 255).toString(16);
    }
    function j(k, l, m) {
        l in c('EmojiStaticConfig').supportedSizes || h(0);
        var n = c('EmojiConfig').pixelRatio + '/' + l + '/' + k + c('EmojiStaticConfig').fileExt,
            o = i(n, c('EmojiStaticConfig').checksumBase);
        return c('EmojiConfig').schemaAuth + '/' + m + o + '/' + n;
    }
    f.exports = {
        getMessengerURL: function k(l, m) {
            return j(l, m, c('EmojiStaticConfig').types.MESSENGER);
        },
        getFBEmojiURL: function k(l) {
            var m = arguments.length <= 1 || arguments[1] === undefined ? 16 : arguments[1];
            return j(l, m, c('EmojiStaticConfig').types.FBEMOJI);
        },
        getFBEmojiExtendedURL: function k(l) {
            var m = arguments.length <= 1 || arguments[1] === undefined ? 16 : arguments[1];
            return j(l, m, c('EmojiStaticConfig').types.FB_EMOJI_EXTENDED);
        }
    };
}), null);
__d("EmojiStaticConfig", [], (function a(b, c, d, e, f, g) {
    f.exports = {
        checksumBase: 317426846,
        fileExt: ".png",
        supportedSizes: {
            "16": "DP16",
            "18": "DP18",
            "20": "DP20",
            "24": "DP24",
            "28": "DP28",
            "30": "DP30",
            "32": "DP32",
            "64": "DP64",
            "128": "DP128"
        },
        types: {
            FBEMOJI: "f",
            FB_EMOJI_EXTENDED: "e",
            MESSENGER: "z",
            UNICODE: "u"
        },
        sizeMap: {
            dp16: 16,
            dp18: 18,
            dp20: 20,
            dp24: 24,
            dp28: 28,
            dp30: 30,
            dp32: 32,
            dp64: 64,
            dp128: 128,
            xsmall: 16,
            small: 32,
            medium: 64,
            large: 128
        }
    };
}), null);
__d("SupportedFBEmoji", [], (function a(b, c, d, e, f, g) {
    f.exports = {
        "1f004": 1,
        /* … flag: sequence: */
        "1f1e6_1f1e8": 1,
        /* … */
        "1f201": 1,
        /* … ???: */
        "1f313_20": 1,
        /* … skin tone modifier (U+1F3FB–F) sequences: */
        "1f385": 1,
        "1f385_1f3fb": 1,
        "1f385_1f3fc": 1,
        "1f385_1f3fd": 1,
        "1f385_1f3fe": 1,
        "1f385_1f3ff": 1,
        /* … ZWJ (U+200D) sequence with optional skin tone modifier: */
        "1f3c3": 1,
        "1f3c3_1f3f": 1,
        "1f3c3_1f3fb": 1,
        "1f3c3_1f3fb_200d_2642": 1,
        "1f3c3_1f3fc": 1,
        "1f3c3_1f3fc_200d_2642": 1,
        "1f3c3_1f3fd": 1,
        "1f3c3_1f3fd_200d_2642": 1,
        "1f3c3_1f3fe": 1,
        "1f3c3_1f3fe_200d_2642": 1,
        "1f3c3_1f3ff": 1,
        "1f3c3_1f3ff_200d_2642": 1,
        "1f3c3_200d_2642": 1,
        /* … ZWJ sequence with optional emoji variation selector (VS-16, U+FE0F): */
        "1f3f3": 1,
        "1f3f3_200d_1f308": 1,
        "1f3f3_fe0f_200d_1f308": 1,
        /* … simple ZWJ sequence: */
        "1f441": 1,
        "1f441_200d_1f5e8": 1,
        /* … one of many complex (family) ZWJ sequences: */
        "1f468_1f3ff_200d_1f468_1f3ff_200d_1f466_1f3ff_200d_1f466_1f3ff": 1,
        /* … some preliminary Unicode 10.0 characters: */
        "1f997": 1,
        "1f9c0": 1,
        "1f9d0": 1,
        "1f9e0": 1,
        "1f9e2": 1,
        "1f9e3": 1,
        "1f9e4": 1,
        /* … code point below U+1000, combining key cap (U+20E3) sequence: */
        "23_20e3": 1,
        "23_fe0f_20e3": 1,
        /* … optional VS-16: */
        "2764": 1,
        "2764_fe0f": 1,
        /* … */
        "": 1,
        a9: 1,
        ae: 1
    };
}), null);
__d('EmojiLikeConstants', ['EmojiStaticConfig'], (function a(b, c, d, e, f, g) {
    'use strict';
    var h = c('EmojiStaticConfig').sizeMap,
        i = {
            XSMALL: 'xsmall',
            SMALL: 'small',
            MEDIUM: 'medium',
            LARGE: 'large'
        },
        j = {
            dp16: 'xsmall',
            dp32: 'small',
            dp64: 'medium',
            db64: 'medium',
            dp128: 'large'
        },
        k = {
            PICKER: 'picker',
            HOT_LIKE: 'hot_like'
        },
        l = [983040],
        m = 'hot_emoji_source',
        n = 'hot_emoji_size',
        o = 'emoji_like',
        p = '\uD83D\uDC4D',
        q = [128077];
    f.exports = {
        FB_THUMBS_UP_EMOJI: l,
        size: i,
        sizeMap: h,
        sizeMapTransfer: j,
        source: k,
        SOURCE_TAG_PREFIX: m,
        TAG_PREFIX_NEW: n,
        TAG_PREFIX_OLD: o,
        THUMBS_UP_EMOJI: p,
        THUMBS_UP_EMOJI_CODES: q
    };
}), null);

from emoji-data.

Crissov avatar Crissov commented on June 1, 2024

I turned that into a gist which (currently) works. Haven’t tried older versions than v7.

from emoji-data.

iamcal avatar iamcal commented on June 1, 2024

messenger images have landed on master, but no facebook.com images yet

from emoji-data.

Crissov avatar Crissov commented on June 1, 2024

I figured it out, I guess, and updated the Gist.

Only the few Unicode 10 emojis are available with size set to 128. However, even those are not available at 64 pixels (despite what it says in the source code). Every emoji is available for 16, 18, 20, 24, 28, 30 and 32 (except the missing Unicode 10 ones)! To get images larger than 32 by 32 pixels, one can increase the pixelRatio to 1.5, 2 or 3 (othere values may work as well) – 2 × 32px make 64 pixels, but 128px is not possible. The high-resolution version can be upscaled, too, i.e. 3 × 128px = 384px.

The digit after emoji.php/v does not seem to matter at all. Facebook itself seems to be using only v7 and v8 currently, though.

from emoji-data.

iamcal avatar iamcal commented on June 1, 2024

good find! i'm building the facebook set now (32, 3x -> 96px source images)

from emoji-data.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.