Tripadvisor precise note

Display the exact Tripadvisor note after the "bubbles"

  1. // ==UserScript==
  2. // @name Tripadvisor precise note
  3. // @description Display the exact Tripadvisor note after the "bubbles"
  4. // @namespace KrisWebDev
  5. // @author KrisWebDev
  6. // @include http://www.tripadvisor.tld/*
  7. // @include https://www.tripadvisor.tld/*
  8. // @version 1.4
  9. // @grant none
  10. // @require http://code.jquery.com/jquery-2.1.4.min.js
  11. // ==/UserScript==
  12.  
  13. this.$ = this.jQuery = jQuery.noConflict(true);
  14.  
  15. var coeff = 5;
  16. var result = 0;
  17. var sumReviews = 0;
  18. var percentReviews = 0;
  19.  
  20. $(".reviews .row_count").each(function(index, val) {
  21. //console.log($(this).text());
  22. percentReviews = parseInt($(this).text().replace(/\s+/g, ''));
  23. result += percentReviews*coeff--;
  24. sumReviews += percentReviews;
  25. });
  26.  
  27. if (sumReviews) {
  28. result = (Math.round(result/sumReviews*10))/10;
  29. $(".reviews .overallRating").text(result+" ");
  30. }