extension/script.js
/**
 * Extracts a number from twitter-formatted text based on the locale set by the user.
 * @param text {string} The text to parse.
 * @return {number} The extracted value.
 */
Extracts a number from twitter-formatted text based on the locale set by the user.
@param text {string} The text to parse.
@return {number} The extracted value.
Extracts a number from twitter - formatted text based on the locale set by the user . @param text { string } The text to parse . @return { number } The extracted value .
function extractNumberFromFormattedText(text) {
    const baseText = text || "0";
    const lang = document.documentElement.lang;
    switch (lang) {
        case "en-GB":
        case "en": return extractNumberFormatEN(baseText);
        case "de": return extractNumberFormatGeneral(baseText, [null, "Mio"]);
        case "sv": return extractNumberFormatGeneral(baseText, ["tn", "mn"]);
        case "es": return extractNumberFormatGeneral(baseText, ["mil", "M"]);
        case "pt": return extractNumberFormatGeneral(baseText, ["mil", "mi"]);
        case "it": return extractNumberFormatGeneral(baseText, [null, "Mln"]);
        case "uk": return extractNumberFormatGeneral(baseText, ["тис", "млн"]);
        case "fr": return extractNumberFormatGeneral(baseText, ["k", "M"]);
        default: {
            console.error("Ratio'd: Unsupported locale, defaulting to english format. Results will likely not be correct.");
            return extractNumberFormatEN(baseText);
        }
    }
}
function extractNumberFromFormattedText ( text ) { const baseText = text || "0" ; const lang = document . documentElement . lang ; switch ( lang ) { case "en-GB" : case "en" : return extractNumberFormatEN ( baseText ) ; case "de" : return extractNumberFormatGeneral ( baseText , [ null , "Mio" ] ) ; case "sv" : return extractNumberFormatGeneral ( baseText , [ "tn" , "mn" ] ) ; case "es" : return extractNumberFormatGeneral ( baseText , [ "mil" , "M" ] ) ; case "pt" : return extractNumberFormatGeneral ( baseText , [ "mil" , "mi" ] ) ; case "it" : return extractNumberFormatGeneral ( baseText , [ null , "Mln" ] ) ; case "uk" : return extractNumberFormatGeneral ( baseText , [ "тис", " м н"]); case "fr" : return extractNumberFormatGeneral ( baseText , [ "k" , "M" ] ) ; default : { console . error ( "Ratio'd: Unsupported locale, defaulting to english format. Results will likely not be correct." ) ; return extractNumberFormatEN ( baseText ) ; } } }
Extracts a number from twitter-formatted text based on the locale set by the user.
Extracts a number from twitter - formatted text based on the locale set by the user .