Skip to content

Instantly share code, notes, and snippets.

@kriswebdev
Last active August 9, 2020 14:37
Show Gist options
  • Save kriswebdev/e6a0e9e65ff8c601b87d to your computer and use it in GitHub Desktop.
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)
// ==UserScript==
// @name Tripadvisor precise note
// @description Display the exact Tripadvisor note after the "bubbles"
// @namespace KrisWebDev
// @author KrisWebDev
// @include http://www.tripadvisor.tld/*
// @version 1.3
// @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