extension/script.js
/**
 * Creates a ratio bar element to append to a tweet.
 * @param {number} score The score to use as a base for colors and texts.
 * @param {string} mode The mode the score is calculated with.
 * @returns {HTMLElement} The ratio bar, unattached.
 */
Creates a ratio bar element to append to a tweet.
@param {number} score The score to use as a base for colors and texts.
@param {string} mode The mode the score is calculated with.
@returns {HTMLElement} The ratio bar, unattached.
Creates a ratio bar element to append to a tweet . @param { number } score The score to use as a base for colors and texts . @param { string } mode The mode the score is calculated with . @returns { HTMLElement } The ratio bar unattached .
function createRatioBar(score, mode) {
    const level = determineLevel(score, mode);
    const ratioBar = document.createElement("div");
    ratioBar.style.width = "100%";
    ratioBar.style.height = "25px";
    ratioBar.style.marginTop = "15px";
    ratioBar.style.backgroundColor = level.bg;
    ratioBar.style.color = level.fnt;
    ratioBar.style.display = "flex";
    ratioBar.style.flexDirection = "row";
    ratioBar.style.fontFamily = `TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`;
    ratioBar.style.alignItems = "center";
    ratioBar.style.borderRadius = "10px";
    ratioBar.style.boxSizing = "border-box";
    ratioBar.style.paddingLeft = "11px";
    ratioBar.style.paddingRight = "11px";
    const statusText = document.createElement("span");
    statusText.style.fontWeight = "500";
    statusText.style.marginRight = "5px";
    statusText.textContent = "RATIO:";
    ratioBar.appendChild(statusText);
    const infoText = document.createElement("span");
    infoText.textContent = level.quip;
    ratioBar.appendChild(infoText);
    const scoreText = document.createElement("span");
    scoreText.textContent = `(${score.toFixed(1)}${mode === RICHTER_MODE ? " Ratio Richter" : ""})`;
    scoreText.style.marginLeft = "auto";
    ratioBar.appendChild(scoreText);
    return ratioBar;
}
function createRatioBar ( score , mode ) { const level = determineLevel ( score , mode ) ; const ratioBar = document . createElement ( "div" ) ; ratioBar . style . width = "100%" ; ratioBar . style . height = "25px" ; ratioBar . style . marginTop = "15px" ; ratioBar . style . backgroundColor = level . bg ; ratioBar . style . color = level . fnt ; ratioBar . style . display = "flex" ; ratioBar . style . flexDirection = "row" ; ratioBar . style . fontFamily = ` ` ; ratioBar . style . alignItems = "center" ; ratioBar . style . borderRadius = "10px" ; ratioBar . style . boxSizing = "border-box" ; ratioBar . style . paddingLeft = "11px" ; ratioBar . style . paddingRight = "11px" ; const statusText = document . createElement ( "span" ) ; statusText . style . fontWeight = "500" ; statusText . style . marginRight = "5px" ; statusText . textContent = "RATIO:" ; ratioBar . appendChild ( statusText ) ; const infoText = document . createElement ( "span" ) ; infoText . textContent = level . quip ; ratioBar . appendChild ( infoText ) ; const scoreText = document . createElement ( "span" ) ; scoreText . textContent = ` ${ score . toFixed ( 1 ) } ${ mode === RICHTER_MODE ? " Ratio Richter" : "" } ` ; scoreText . style . marginLeft = "auto" ; ratioBar . appendChild ( scoreText ) ; return ratioBar ; }
Creates a ratio bar element to append to a tweet.
Creates a ratio bar element to append to a tweet .
// Base bar. // Static text - "RATIO:". // Level text stating the quality of the tweet. // Text at the end of the bar, stating the exact score.