Amazon show absolute review numbers

Adds the number of reviews to each rating separately

2018-06-08 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Amazon show absolute review numbers
// @namespace    graphen
// @version      0.1.0
// @description  Adds the number of reviews to each rating separately
// @author       Graphen
// @include      /^https?:\/\/www\.amazon\.(cn|in|co\.jp|sg|fr|de|it|nl|es|co\.uk|ca|com(\.(mx|au|br))?)\/.*$/
// @icon         https://www.amazon.com/favicon.ico
// @grant        none
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */

(function() {
    'use strict';

    var totalReviewCount = document.querySelector(".totalReviewCount").innerText;
    // Sanitize totalReviewCount in case site has changed and selector returns nonsense
    // Remove all non-digits
    totalReviewCount = totalReviewCount.replace(/\D/g, '');
    // Convert string to integer
    totalReviewCount = parseInt(totalReviewCount, 10);
    // Most reviewed product has ~100000 at the moment
    if (totalReviewCount < 250000) {
        const arrPercentages = Array.from(document.querySelectorAll("#histogramTable .a-text-right > *:first-child"));
        for (var e of arrPercentages) {
            let v = e.innerText;
            // Get rid of percentage sign and convert string to integer
            v = parseInt(v, 10);
            // Calculate absolute review count
            v = Math.round(v * totalReviewCount / 100);
            // Cancel if nonsense
            if (v > totalReviewCount || v < 0) {
                break;
            }
            // Append calculated value to visible node
            e.textContent += " (" + v + ")";
        }
    }

})();