|
6 | 6 | // @supportURL https://github.com/0xdevalias/userscripts/issues
|
7 | 7 | // @downloadURL https://github.com/0xdevalias/userscripts/raw/main/userscripts/nourishd-meal-highlighter/nourishd-meal-highlighter.user.js
|
8 | 8 | // @namespace https://www.devalias.net/
|
9 |
| -// @version 0.1.4 |
10 |
| -// @match https://nourishd.com.au/account |
| 9 | +// @version 0.1.5 |
| 10 | +// @match https://nourishd.com.au/menu |
11 | 11 | // @grant none
|
12 | 12 | // ==/UserScript==
|
13 | 13 |
|
|
139 | 139 |
|
140 | 140 | const validPortionSizes = ["Regular", "Large", "Extra Large"];
|
141 | 141 |
|
142 |
| - const mealsContainerSelector = 'div[x-show="currentTab === \'my-meals\'"]'; |
143 |
| - const mealTitleSelector = 'div > a > h4'; |
144 |
| - const mealsSelector = 'div > div:has(> a > div.meal-slider-image)'; |
| 142 | + const mealsContainerSelector = 'main .container'; |
| 143 | + const mealsSelector = '.product-card'; |
| 144 | + const mealTitleSelector = '.add-to-cart-box a'; |
145 | 145 | const mealImageSelector = '.meal-slider-image > img, .meal-slider-image > video';
|
146 | 146 | const mealSizeQuantityAddSectionSelector = 'div:has(div > div > div > select), div:has(div > div > div > input)';
|
147 | 147 |
|
|
180 | 180 | }
|
181 | 181 |
|
182 | 182 | function setDefaultPortionSize(meal, portionSize) {
|
183 |
| - const selectElement = meal.querySelector('select[name="product_variant"]'); |
| 183 | + const selectElement = meal.querySelector('select[wire\\:model="selectedVariantId"]'); |
| 184 | + |
184 | 185 | if (selectElement && portionSize) {
|
185 | 186 | const desiredOption = Array.from(selectElement.options).find((option) =>
|
186 | 187 | option.textContent.includes(portionSize)
|
|
210 | 211 |
|
211 | 212 | debugLog('processMeals->meals.forEach', title, { titleElement, meal });
|
212 | 213 |
|
213 |
| - if (!title) return; |
214 |
| - |
215 |
| - if (mealsToHighlight.includes(title)) { |
216 |
| - debugLog('processMeals->meals.forEach->mealsToHighlight.includes', title); |
217 |
| - |
218 |
| - styleAsHighlighted(meal); |
219 |
| - } else if (mealsToIgnore.includes(title)) { |
220 |
| - debugLog('processMeals->meals.forEach->mealsToIgnore.includes', title); |
221 |
| - |
222 |
| - styleAsIgnored(meal); |
223 |
| - } else { |
224 |
| - debugLog('processMeals->meals.forEach->unknown', title); |
225 |
| - |
226 |
| - styleAsUnknown(meal); |
| 214 | + if (title) { |
| 215 | + if (mealsToHighlight.includes(title)) { |
| 216 | + debugLog('processMeals->meals.forEach->mealsToHighlight.includes', title); |
| 217 | + |
| 218 | + styleAsHighlighted(meal); |
| 219 | + } else if (mealsToIgnore.includes(title)) { |
| 220 | + debugLog('processMeals->meals.forEach->mealsToIgnore.includes', title); |
| 221 | + |
| 222 | + styleAsIgnored(meal); |
| 223 | + } else { |
| 224 | + debugLog('processMeals->meals.forEach->unknown', title); |
| 225 | + |
| 226 | + styleAsUnknown(meal); |
| 227 | + } |
| 228 | + |
| 229 | + // Removing the excess padding/margin below the meal image |
| 230 | + // meal.classList.remove('pb-10', 'mb-10'); |
| 231 | + // meal.classList.add('mb-2'); |
| 232 | + |
| 233 | + // Ensure the meal title contrasts against the background |
| 234 | + titleElement.classList.add("text-white"); |
| 235 | + // meal.classList.add("text-white"); |
| 236 | + |
| 237 | + // TODO: Re-add something here to make it reduce the size of the entire box to fit the smaller image? |
| 238 | + // const mealImageElement = meal.querySelector(mealImageSelector); |
| 239 | + // debugLog('mealImageElement', { mealImageElement }); |
| 240 | + // if (mealImageElement) { |
| 241 | + // mealImageElement.classList.remove('w-full', 'h-full'); |
| 242 | + // mealImageElement.classList.add('w-1/2', 'h-1/2', 'mx-auto'); |
| 243 | + // } |
| 244 | + |
| 245 | + // const sizeQuantityAddMealSection = meal.querySelector(mealSizeQuantityAddSectionSelector); |
| 246 | + // debugLog('sizeQuantityAddMealSection', { sizeQuantityAddMealSection }); |
| 247 | + // if (sizeQuantityAddMealSection) { |
| 248 | + // // Ensure there is an even amount of left/right padding around the size/quanity/etc section |
| 249 | + // sizeQuantityAddMealSection.classList.remove("md:pl-6") |
| 250 | + // sizeQuantityAddMealSection.classList.add("px-6") |
| 251 | + // } |
227 | 252 | }
|
228 | 253 |
|
229 | 254 | // Select our desired portion size in the dropdown
|
230 | 255 | setDefaultPortionSize(meal, defaultPortionSize);
|
231 |
| - |
232 |
| - // Removing the excess padding/margin below the meal image |
233 |
| - meal.classList.remove('pb-10', 'mb-10'); |
234 |
| - meal.classList.add('mb-2'); |
235 |
| - |
236 |
| - // Ensure the meal title contrasts against the background |
237 |
| - titleElement.classList.add("text-white"); |
238 |
| - |
239 |
| - const mealImageElement = meal.querySelector(mealImageSelector); |
240 |
| - debugLog('mealImageElement', { mealImageElement }); |
241 |
| - if (mealImageElement) { |
242 |
| - mealImageElement.classList.remove('w-full', 'h-full'); |
243 |
| - mealImageElement.classList.add('w-1/2', 'h-1/2', 'mx-auto'); |
244 |
| - } |
245 |
| - |
246 |
| - const sizeQuantityAddMealSection = meal.querySelector(mealSizeQuantityAddSectionSelector); |
247 |
| - debugLog('sizeQuantityAddMealSection', { sizeQuantityAddMealSection }); |
248 |
| - if (sizeQuantityAddMealSection) { |
249 |
| - // Ensure there is an even amount of left/right padding around the size/quanity/etc section |
250 |
| - sizeQuantityAddMealSection.classList.remove("md:pl-6") |
251 |
| - sizeQuantityAddMealSection.classList.add("px-6") |
252 |
| - } |
253 | 256 | });
|
254 | 257 | }
|
255 | 258 |
|
|
0 commit comments