extension/script.js
/**
 * Depending on the mode, calculates if a ratio bar should be applied and applies it if needed.
 * @param {HTMLElement} tweetContent The element to append the bar to.
 * @param {object} ratios The ratios object generated by the makeScores function.
 * @param {string} mode The calculation method used for display. 
 */
Depending on the mode, calculates if a ratio bar should be applied and applies it if needed.
@param {HTMLElement} tweetContent The element to append the bar to.
@param {object} ratios The ratios object generated by the makeScores function.
@param {string} mode The calculation method used for display.
Depending on the mode calculates if a ratio bar should be applied and applies it if needed . @param { HTMLElement } tweetContent The element to append the bar to . @param { object } ratios The ratios object generated by the makeScores function . @param { string } mode The calculation method used for display .
function checkAndApplyRatioBar(tweetContent, ratios, mode) {
    const isRichter = mode === RICHTER_MODE;
    const upperBound = isRichter ? OPTIONS.richterThresholdNegative :
        OPTIONS.balancedThresholdPositive;
    const lowerBound = isRichter ? OPTIONS.richterThresholdPositive :
        OPTIONS.balancedThresholdNegative;
    const score = isRichter ? ratios.ratioRichter : ratios.balancedScore;
    const isPositive = isRichter ? score <= OPTIONS.richterLevelGood : score >= OPTIONS.balancedLevelGood;
    const isBlocked = OPTIONS.behavior === "NEGATIVE_ONLY" && isPositive;
    if (!isBlocked && (score >= upperBound || score <= lowerBound)) {
        const ratioBar = createRatioBar(score, mode);
        tweetContent.appendChild(ratioBar);
    }
}
function checkAndApplyRatioBar ( tweetContent , ratios , mode ) { const isRichter = mode === RICHTER_MODE ; const upperBound = isRichter ? OPTIONS . richterThresholdNegative : OPTIONS . balancedThresholdPositive ; const lowerBound = isRichter ? OPTIONS . richterThresholdPositive : OPTIONS . balancedThresholdNegative ; const score = isRichter ? ratios . ratioRichter : ratios . balancedScore ; const isPositive = isRichter ? score <= OPTIONS . richterLevelGood : score >= OPTIONS . balancedLevelGood ; const isBlocked = OPTIONS . behavior === "NEGATIVE_ONLY" && isPositive ; if ( ! isBlocked && ( score >= upperBound || score <= lowerBound ) ) { const ratioBar = createRatioBar ( score , mode ) ; tweetContent . appendChild ( ratioBar ) ; } }
Depending on the mode, calculates if a ratio bar should be applied and applies it if needed.
Depending on the mode calculates if a ratio bar should be applied and applies it if needed .
// We don't want to display a bar for every tweet, only the notable ones. // Therefore we have an "exclusion zone" of irrelevant scores, which changes depending // on the scale/mode of calculation that is used. // In default mode, we only display negative tweets (because green bars are boring and no one's here for it).