diff --git a/manifest.json b/manifest.json index 9fcec39..27f4b41 100644 --- a/manifest.json +++ b/manifest.json @@ -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" } diff --git a/myscript.js b/myscript.js index c38e12a..24c80b8 100644 --- a/myscript.js +++ b/myscript.js @@ -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) + ' (' + score.toFixed(2) + ")"); - $(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) + ' (' + score.toFixed(2) + ")"); + 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) + ' (' + score.toFixed(2) + ")"); - $(element).find(".star").removeClass().addClass("star star" + honest * 10); + var honest = honestify(score); + $(element).html(honest.toFixed(1) + ' (' + score.toFixed(2) + ")"); + var rate = $(".tb-rating", parent)[0]; + rate.className = rate.className.replace(/tb-rating--val\d\d/, "tb-rating--val" + honest * 10); + }); }); }