Last active
August 9, 2020 14:37
-
-
Save kriswebdev/e6a0e9e65ff8c601b87d to your computer and use it in GitHub Desktop.
Better Tripadvisor: Precise ratings, website link, phone, google search (click Raw to install with e.g. Tampermonkey)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tripadvisor precise note | |
// @description Display the exact Tripadvisor note after the "bubbles" | |
// @namespace KrisWebDev | |
// @author KrisWebDev | |
// @include http://www.tripadvisor.fr/* | |
// @include http://www.tripadvisor.com/* | |
// @include http://www.tripadvisor.tld/* | |
// @version 1.2 | |
// @grant none | |
// @require http://code.jquery.com/jquery-2.1.4.min.js | |
// ==/UserScript== | |
this.$ = this.jQuery = jQuery.noConflict(true); | |
var coeff = 5; | |
var result = 0; | |
var sommeAvis = 0; | |
var pourcentAvis = 0; | |
$(".reviews .row_count").each(function(index, val) { | |
//console.log($(this).text()); | |
pourcentAvis = parseInt($(this).text().replace(/\s+/g, '')); | |
result += pourcentAvis*coeff--; | |
sommeAvis += pourcentAvis; | |
}); | |
if (sommeAvis) { | |
result = (Math.round(result/sommeAvis*10))/10; | |
$(".reviews .overallRating").text(result+" "); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment