Skip to content

Commit

Permalink
Merge develop into master
Browse files Browse the repository at this point in the history
Merge develop into master for release
  • Loading branch information
Rohaq committed Jul 16, 2017
2 parents 857e764 + 645df82 commit bd67f7e
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 57 deletions.
5 changes: 0 additions & 5 deletions fsabg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
45 changes: 39 additions & 6 deletions fsainsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -27,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();
Expand All @@ -40,11 +46,17 @@ 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();
businessPostcode = businessPostcode.replace(/^(.{3,4})(.{3})$/, "$1 $2");
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;
}

Expand Down Expand Up @@ -95,18 +107,39 @@ 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$/)) {
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';
}
targetOp = 'after';
break;
}

switch (targetOp) {
case 'append':
$(targetElement).append(ratingContent);
break;
case 'after':
$(targetElement).after(ratingContent);
break;
}
$(targetElement).append(ratingContent);
});
99 changes: 56 additions & 43 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,79 @@
"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",
"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/*/menu",
"https://www.just-eat.co.uk/*/menu#*"
],
"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"
}],
],
"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,
"scripts": [
"fsabg.js",
"jquery-3.2.1.min.js"
]
"fsabg.js",
"jquery-3.2.1.min.js"
]
},
"permissions": [
"http://ratings.food.gov.uk/*"
],
"web_accessible_resources": [
"/images/ratings/*"
]
}
}
11 changes: 11 additions & 0 deletions styles/deliveroo.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ div.fsapanel {
margin: 5px;
font-size: 12px;
text-align: center;
padding: 5px;
}

p.fsadate {
Expand All @@ -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;
}
16 changes: 13 additions & 3 deletions styles/hungryhouse.css
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
}
Expand All @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions styles/justeat.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
div.fsapanel {
margin: 5px;
padding: 5px;
font-size: 12px;
max-width: 120px;
text-align: center;
Expand All @@ -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;
}
30 changes: 30 additions & 0 deletions styles/kukd.css
Original file line number Diff line number Diff line change
@@ -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: rgb(213, 226, 86);
color: black;
}

0 comments on commit bd67f7e

Please sign in to comment.