Skip to content

Commit

Permalink
update HTML/JS and support https
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Jan 5, 2017
1 parent 1aada39 commit b98d8e9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
7 changes: 4 additions & 3 deletions manifest.json
Expand Up @@ -2,14 +2,15 @@
"manifest_version": 2,
"name": "Tabelog Honest Stars",
"description": "Display Tabelog Stars in Honest Scale",
"version": "1.0.2",
"version": "1.0.3",
"permissions": [
"tabs",
"http://tabelog.com/*"
"http://tabelog.com/*",
"https://tabelog.com/*"
],
"content_scripts": [
{
"matches": ["http://tabelog.com/*"],
"matches": ["http://tabelog.com/*", "https://tabelog.com/*"],
"js": ["myscript.js"],
"run_at": "document_end"
}
Expand Down
33 changes: 20 additions & 13 deletions myscript.js
Expand Up @@ -21,23 +21,30 @@ function patch(){
return honest;
};

$('.rate .score').each(function(index, element) {
var score = parseFloat($(element).text());
if (isNaN(score)) return;
$(".rdheader-data").each(function() {
var parent = this;
$('[rel="v:rating"] span', parent).each(function(index, element) {
var score = parseFloat($(element).text());
if (isNaN(score)) return;

var honest = honestify(score);
$(element).html(honest.toFixed(1) + ' <span class="tabelog-score">(' + score.toFixed(2) + ")</span>");
$(element).parent().find("img")
.attr("src", "http://image1-3.tabelog.k-img.com/images/restaurant/star/star_ll" + (honest * 10) + ".gif");
var honest = honestify(score);
$(element).html(honest.toFixed(1) + ' <span class="tabelog-score">(' + score.toFixed(2) + ")</span>");
var rate = $(".tb-rating", parent)[0];
rate.className = rate.className.replace(/tb-rating--val\d\d/, "tb-rating--val" + honest * 10);
});
});

$(".info .score-overall").each(function(index, element) {
var score = parseFloat($(element).find(".score").text());
if (isNaN(score)) return;
$(".list-rst").each(function() {
var parent = this;
$(".tb-rating__val", parent).each(function(index, element) {
var score = parseFloat($(element).text());
if (isNaN(score)) return;

var honest = honestify(score);
$(element).find(".score").html(honest.toFixed(1) + ' <span class="tabelog-score">(' + score.toFixed(2) + ")</span>");
$(element).find(".star").removeClass().addClass("star star" + honest * 10);
var honest = honestify(score);
$(element).html(honest.toFixed(1) + ' <span class="tabelog-score">(' + score.toFixed(2) + ")</span>");
var rate = $(".tb-rating", parent)[0];
rate.className = rate.className.replace(/tb-rating--val\d\d/, "tb-rating--val" + honest * 10);
});
});
}

Expand Down

0 comments on commit b98d8e9

Please sign in to comment.