extension/script.js
/**
 * Extracts a twitter-formatted number using the English locale.
 * @param text {string} The text to parse.
 * @return {number} The extracted value.
 */
Extracts a twitter-formatted number using the English locale.
@param text {string} The text to parse.
@return {number} The extracted value.
Extracts a twitter - formatted number using the English locale . @param text { string } The text to parse . @return { number } The extracted value .
function extractNumberFormatEN(text) {
    text = text.replace(/,/g, "");
    const amplifierMap = {
        "K": 1000,
        "M": 1000000
    };
    const matchResults = /([0-9]+(\.[0-9]+)?)([KM])?/g.exec(text);
    let num = parseFloat(matchResults[1]);
    const amplifier = amplifierMap[matchResults[3]];
    if (amplifier) num *= amplifier;
    return num;
}
function extractNumberFormatEN ( text ) { text = text . replace ( / , / g , "" ) ; const amplifierMap = { "K" : 1000 , "M" : 1000000 } ; const matchResults = / ([0-9]+(\.[0-9]+)?)([KM])? / g . exec ( text ) ; let num = parseFloat ( matchResults [ 1 ] ) ; const amplifier = amplifierMap [ matchResults [ 3 ] ] ; if ( amplifier ) num *= amplifier ; return num ; }
Extracts a twitter-formatted number using the English locale.
Extracts a twitter - formatted number using the English locale .