From 676665260c9f1e6813f7c7777e7776ae35727ddc Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 04:13:58 +0100 Subject: [PATCH 01/10] Removed unneeded block from fsabg.js - Was previously in place in case we wanted to handle multiple results. --- fsabg.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fsabg.js b/fsabg.js index 7b7d44f..31ac365 100644 --- a/fsabg.js +++ b/fsabg.js @@ -35,11 +35,6 @@ chrome.runtime.onMessage.addListener( 'date': data.establishments[0].RatingDate, 'results': resultCount }; - } else if (resultCount === 0 ) { - jsonMsg = { - 'success': false, - 'results': resultCount - }; } else { jsonMsg = { 'success': false, From 1fcc32ef3cc875dc40cc84ec0ced08785d5d1623 Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 08:19:07 +0100 Subject: [PATCH 02/10] Removed old console.log debug line. --- fsainsert.js | 1 - 1 file changed, 1 deletion(-) diff --git a/fsainsert.js b/fsainsert.js index bff72df..cd7ade1 100644 --- a/fsainsert.js +++ b/fsainsert.js @@ -40,7 +40,6 @@ switch (currentSite) { case 'deliveroo': businessName = $('div.restaurant--main > div.restaurant__details > h1.restaurant__name').text().replace(/^(.+)-.+/, "$1").trim(); businessAddress = $('div.restaurant--main > div.restaurant__details > div.restaurant__metadata > div.metadata__details > small.address').text().split(','); - console.log(businessName); businessStreet = businessAddress[0].trim(); businessCity = businessAddress[businessAddress.length-2].trim(); businessPostcode = businessAddress[businessAddress.length-1].trim(); From ff014b5d84e6ae33554544bd1bbaf898afb85be7 Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 08:25:12 +0100 Subject: [PATCH 03/10] Amended postcode regex in Deliveroo code to allow for postcodes areas that start with two characters. --- fsainsert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsainsert.js b/fsainsert.js index cd7ade1..fa6bc44 100644 --- a/fsainsert.js +++ b/fsainsert.js @@ -43,7 +43,7 @@ switch (currentSite) { businessStreet = businessAddress[0].trim(); businessCity = businessAddress[businessAddress.length-2].trim(); businessPostcode = businessAddress[businessAddress.length-1].trim(); - businessPostcode = businessPostcode.replace(/^(.{3,4})(.{3})$/, "$1 $2"); + businessPostcode = businessPostcode.replace(/^(.{2,4})(.{3})$/, "$1 $2"); break; } From 4cf3972fa72424bd9694256b441e70a8deee95ba Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 08:32:50 +0100 Subject: [PATCH 04/10] Added support for kukd.com --- fsainsert.js | 17 ++++++++++++++++- manifest.json | 13 +++++++++++++ styles/kukd.css | 30 ++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 styles/kukd.css diff --git a/fsainsert.js b/fsainsert.js index fa6bc44..373e13b 100644 --- a/fsainsert.js +++ b/fsainsert.js @@ -8,7 +8,8 @@ function escapeHtml(str) { var siteLookupTable = { 'www.just-eat.co.uk': 'justeat', 'hungryhouse.co.uk': 'hungryhouse', - 'deliveroo.co.uk': 'deliveroo' + 'deliveroo.co.uk': 'deliveroo', + 'www.kukd.com': 'kukd' }; var currentSite = siteLookupTable[location.hostname]; @@ -45,6 +46,13 @@ switch (currentSite) { businessPostcode = businessAddress[businessAddress.length-1].trim(); businessPostcode = businessPostcode.replace(/^(.{2,4})(.{3})$/, "$1 $2"); break; + case 'kukd': + businessName = $('section.headermaink > div.container:nth-of-type(1) > h1 > b').text().trim(); + businessAddress = $('section.headermaink > div.container:nth-of-type(1) > h2').text().split(','); + businessStreet = businessAddress[0].trim(); + businessCity = businessAddress[businessAddress.length-2].trim(); + businessPostcode = businessAddress[businessAddress.length-1].trim(); + break; } chrome.runtime.sendMessage({ @@ -106,6 +114,13 @@ chrome.runtime.sendMessage({ case 'deliveroo': targetElement = 'div.restaurant__details > div.restaurant__metadata'; break; + case 'kukd': + if (window.location.pathname.match(/\/menu$/)) { + targetElement = 'div#checkoutHide > div.ordermodes:nth-of-type(3)'; + } else if (window.location.pathname.match(/\/(info|reviews)$/)) { + targetElement = 'div.mb40 > div.mt20 > div:first-of-type'; + } + break; } $(targetElement).append(ratingContent); }); diff --git a/manifest.json b/manifest.json index b2e852a..669d34e 100644 --- a/manifest.json +++ b/manifest.json @@ -50,6 +50,19 @@ "/styles/deliveroo.css" ], "run_at": "document_end" + }, + { + "matches": [ + "https://www.kukd.com/restaurant/*" + ], + "js": [ + "jquery-3.2.1.min.js", + "fsainsert.js" + ], + "css": [ + "/styles/kukd.css" + ], + "run_at": "document_end" }], "background": { "persistent": false, diff --git a/styles/kukd.css b/styles/kukd.css new file mode 100644 index 0000000..f79c4ab --- /dev/null +++ b/styles/kukd.css @@ -0,0 +1,30 @@ +div.fsapanel { + margin: 5px; + font-size: 12px; + text-align: center; + width: 170px; + position: relative; + left: 35px; + margin-top: 15px; +} + +p.fsadate { + white-space: nowrap; +} + +label.fsadatelabel { + font-weight: bold; +} + +.fsaheader { + font-weight: bold; +} + +div.fsanorating { + border-color: black; + border-style: solid; + border-width: 1px; + border-radius: 10px; + background-color: yellowgreen; + color: black; +} \ No newline at end of file From 3163d2499f18e5db71b694ff7bf020fdbb853f5f Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 09:18:55 +0100 Subject: [PATCH 05/10] Added background colour to panel when no ratings found that's closer to the one used in the FSA graphics. --- styles/kukd.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/kukd.css b/styles/kukd.css index f79c4ab..84f126c 100644 --- a/styles/kukd.css +++ b/styles/kukd.css @@ -25,6 +25,6 @@ div.fsanorating { border-style: solid; border-width: 1px; border-radius: 10px; - background-color: yellowgreen; + background-color: rgb(213, 226, 86); color: black; } \ No newline at end of file From f4f5daa716abf7174485f1ec07d9db441bd578de Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 09:35:56 +0100 Subject: [PATCH 06/10] Amended styling to add more colour to panel when no rating is found. --- styles/deliveroo.css | 11 +++++++++++ styles/hungryhouse.css | 16 +++++++++++++--- styles/justeat.css | 10 ++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/styles/deliveroo.css b/styles/deliveroo.css index f410f16..a2f74fb 100644 --- a/styles/deliveroo.css +++ b/styles/deliveroo.css @@ -2,6 +2,7 @@ div.fsapanel { margin: 5px; font-size: 12px; text-align: center; + padding: 5px; } p.fsadate { @@ -14,4 +15,14 @@ label.fsadatelabel { .fsaheader { font-weight: bold; +} + +div.fsanorating { + border-color: black; + border-style: solid; + border-width: 1px; + border-radius: 10px; + background-color: rgb(213, 226, 86); + color: black; + width: 150px; } \ No newline at end of file diff --git a/styles/hungryhouse.css b/styles/hungryhouse.css index ad8c010..06656ac 100644 --- a/styles/hungryhouse.css +++ b/styles/hungryhouse.css @@ -6,13 +6,14 @@ div.fsapanel { -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; transform-style: preserve-3d; - top: -20px; + top: -30px; right: -50px; margin-left: 0px !important; + padding: 5px; + margin: 5px; } div.fsapanel > p { - margin: 8px; text-align: center; width: 100%; } @@ -22,7 +23,16 @@ label.fsadatelabel { } div.fsanorating { - right: -20px; + top: -15px; + right: -40px; + border-color: black; + border-style: solid; + border-width: 1px; + border-radius: 10px; + background-color: rgb(213, 226, 86); + color: black; + width: 150px; + height: initial !important; } .fsaheader { diff --git a/styles/justeat.css b/styles/justeat.css index 84068da..6103cfd 100644 --- a/styles/justeat.css +++ b/styles/justeat.css @@ -1,5 +1,6 @@ div.fsapanel { margin: 5px; + padding: 5px; font-size: 12px; max-width: 120px; text-align: center; @@ -11,4 +12,13 @@ label.fsadatelabel { .fsaheader { font-weight: bold; +} + +div.fsanorating { + border-color: black; + border-style: solid; + border-width: 1px; + border-radius: 10px; + background-color: rgb(213, 226, 86); + color: black; } \ No newline at end of file From dcc51515e091521bff37aa6416d63c461fc2bcd5 Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 18:55:16 +0100 Subject: [PATCH 07/10] Added ability to specify append/after jQuery ops to avoid breaking page layouts when adding elements. --- fsainsert.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fsainsert.js b/fsainsert.js index 373e13b..e638a9a 100644 --- a/fsainsert.js +++ b/fsainsert.js @@ -102,17 +102,22 @@ chrome.runtime.sendMessage({ } } - // Finally, append it to the page. + // Finally, add it to the page. var targetElement; + var targetOp; + switch (currentSite) { case 'justeat': targetElement = 'div.restaurantOverview > div.details'; + targetOp = 'append'; break; case 'hungryhouse': targetElement = 'div#restMainInfoWrapper'; + targetOp = 'append'; break; case 'deliveroo': targetElement = 'div.restaurant__details > div.restaurant__metadata'; + targetOp = 'append'; break; case 'kukd': if (window.location.pathname.match(/\/menu$/)) { @@ -120,7 +125,16 @@ chrome.runtime.sendMessage({ } else if (window.location.pathname.match(/\/(info|reviews)$/)) { targetElement = 'div.mb40 > div.mt20 > div:first-of-type'; } + targetOp = 'after'; + break; + } + + switch (targetOp) { + case 'append': + $(targetElement).append(ratingContent); + break; + case 'after': + $(targetElement).after(ratingContent); break; } - $(targetElement).append(ratingContent); }); From e5b0d87899c1a1a2222e2ebc8a6edf10a9b6d801 Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 19:10:15 +0100 Subject: [PATCH 08/10] Added FSA ratings to non-menu restaurant pages for Just Eat and HungryHouse --- fsainsert.js | 7 ++++++- manifest.json | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fsainsert.js b/fsainsert.js index e638a9a..1a06708 100644 --- a/fsainsert.js +++ b/fsainsert.js @@ -28,7 +28,12 @@ switch (currentSite) { businessPostcode = $('div.details > p.address > span#postcode').text().replace(/\s+/g, ' ').trim(); break; case 'hungryhouse': - businessName = $('.restMainInfoHeader > div.headerLeft > h1 > span:nth-of-type(1)').text().replace(/\s+/g, ' ').trim(); + // Because of course they change the header element for the reviews page. + if (window.location.pathname.match(/\/reviews$/)) { + businessName = $('.restMainInfoHeader > div.headerLeft > div.reviewPageRestTitle > span:nth-of-type(1)').text().replace(/\s+/g, ' ').trim(); + } else { + businessName = $('.restMainInfoHeader > div.headerLeft > h1 > span:nth-of-type(1)').text().replace(/\s+/g, ' ').trim(); + } businessStreet = $('.menuAddress > .address > span:nth-of-type(1)').text().replace(/\s+/g, ' ').trim(); businessCity = $('.menuAddress > .address > span:nth-of-type(2)').text().replace(/\s+/g, ' ').trim(); businessPostcode = $('.menuAddress > .address > span:nth-of-type(3)').text().replace(/\s+/g, ' ').trim(); diff --git a/manifest.json b/manifest.json index 669d34e..85575b1 100644 --- a/manifest.json +++ b/manifest.json @@ -13,8 +13,10 @@ }, "content_scripts": [{ "matches": [ - "https://www.just-eat.co.uk/*/menu", - "https://www.just-eat.co.uk/*/menu#*" + "https://www.just-eat.co.uk/restaurants-*/menu", + "https://www.just-eat.co.uk/restaurants-*/menu#*", + "https://www.just-eat.co.uk/restaurants-*/reviews", + "https://www.just-eat.co.uk/restaurants-*" ], "js": [ "jquery-3.2.1.min.js", From f26b4c2be0bfa40874a4184f09168674f218296d Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 19:10:58 +0100 Subject: [PATCH 09/10] Version++ --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 85575b1..0f0e92b 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Takeaway Hygiene Ratings UK", "short_name": "Food Hygiene", - "version": "1.1.1", + "version": "1.2.0", "description": "Adds Food Standard Agency ratings to popular takeaway sites.", "icons": { "16": "/icons/icon_16.png", From 645df82786905171468d9879b4879f89eb0eaf93 Mon Sep 17 00:00:00 2001 From: Rohaq Date: Sun, 16 Jul 2017 20:22:49 +0100 Subject: [PATCH 10/10] Autoindented manifest.json --- manifest.json | 110 +++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/manifest.json b/manifest.json index 0f0e92b..b4c46e8 100644 --- a/manifest.json +++ b/manifest.json @@ -9,69 +9,67 @@ "32": "/icons/icon_32.png", "64": "/icons/icon_64.png", "128": "/icons/icon_128.png", - "256": "/icons/icon_256.png" + "256": "/icons/icon_256.png" }, "content_scripts": [{ - "matches": [ - "https://www.just-eat.co.uk/restaurants-*/menu", - "https://www.just-eat.co.uk/restaurants-*/menu#*", - "https://www.just-eat.co.uk/restaurants-*/reviews", - "https://www.just-eat.co.uk/restaurants-*" - ], - "js": [ - "jquery-3.2.1.min.js", - "fsainsert.js" - ], - "css": [ - "/styles/justeat.css" - ], - "run_at": "document_end" - }, - { - "matches": [ - "https://hungryhouse.co.uk/*" - ], - "js": [ - "jquery-3.2.1.min.js", - "fsainsert.js" - ], - "css": [ + "matches": [ + "https://www.just-eat.co.uk/restaurants-*/menu", + "https://www.just-eat.co.uk/restaurants-*/menu#*", + "https://www.just-eat.co.uk/restaurants-*/reviews", + "https://www.just-eat.co.uk/restaurants-*" + ], + "js": [ + "jquery-3.2.1.min.js", + "fsainsert.js" + ], + "css": [ + "/styles/justeat.css" + ], + "run_at": "document_end" + }, { + "matches": [ + "https://hungryhouse.co.uk/*" + ], + "js": [ + "jquery-3.2.1.min.js", + "fsainsert.js" + ], + "css": [ "/styles/hungryhouse.css" - ], - "run_at": "document_end" - }, - { - "matches": [ - "https://deliveroo.co.uk/*" - ], - "js": [ - "jquery-3.2.1.min.js", - "fsainsert.js" - ], - "css": [ + ], + "run_at": "document_end" + }, { + "matches": [ + "https://deliveroo.co.uk/*" + ], + "js": [ + "jquery-3.2.1.min.js", + "fsainsert.js" + ], + "css": [ "/styles/deliveroo.css" - ], - "run_at": "document_end" - }, - { - "matches": [ - "https://www.kukd.com/restaurant/*" - ], - "js": [ - "jquery-3.2.1.min.js", - "fsainsert.js" - ], - "css": [ + ], + "run_at": "document_end" + }, { + "matches": [ + "https://www.kukd.com/restaurant/*" + ], + "js": [ + "jquery-3.2.1.min.js", + "fsainsert.js" + ], + "css": [ "/styles/kukd.css" - ], - "run_at": "document_end" - }], + ], + "run_at": "document_end" + } + ], "background": { "persistent": false, "scripts": [ - "fsabg.js", - "jquery-3.2.1.min.js" - ] + "fsabg.js", + "jquery-3.2.1.min.js" + ] }, "permissions": [ "http://ratings.food.gov.uk/*" @@ -79,4 +77,4 @@ "web_accessible_resources": [ "/images/ratings/*" ] -} \ No newline at end of file +}