Skip to content

Instantly share code, notes, and snippets.

@havardox
Created March 13, 2026 15:33
Show Gist options
  • Select an option

  • Save havardox/d386b9da4b8e7737a6735ee937387b48 to your computer and use it in GitHub Desktop.

Select an option

Save havardox/d386b9da4b8e7737a6735ee937387b48 to your computer and use it in GitHub Desktop.
A TamperMonkey script that takes a food item on https://mcdonalds.ee and copies the name, calories, and macros to clipboard for Excel.
// ==UserScript==
// @name McDonald's EE copy nutrition to clipboard
// @namespace havardox
// @version 0.1
// @description Takes a food item on https://mcdonalds.ee and copies the name, calories, and macros to clipboard for Excel.
// @author Harald Varner
// @match https://mcdonalds.ee/tooted/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=mcdonalds.ee
// @grant GM_setClipboard
// ==/UserScript==
(function () {
'use strict';
// Set a slight delay to ensure Elementor accordions/widgets are fully parsed
setTimeout(() => {
// Get title element
let titleEl = document.querySelector("h1.elementor-heading-title");
if (!titleEl) {
// Skip everything if title is missing
return;
}
let clipboard = "";
// Clean and prepare title
let title = titleEl.innerText.trim();
clipboard += title;
// Helper function to extract nutrient values (Portion values are in the 3rd column/div)
const getNutrientValue = (labelSearch) => {
const rows = document.querySelectorAll(".detailed .detailed-row.values");
for (let row of rows) {
const divs = row.querySelectorAll("div");
// Structure: Div 0 = Label, Div 1 = per 100g, Div 2 = per portion, Div 3 = RI %
if (divs.length >= 3) {
const label = divs[0].textContent.trim();
if (label.toLowerCase().includes(labelSearch.toLowerCase())) {
return divs[2].textContent.trim() || "0";
}
}
}
return "";
};
// Extracting standard nutritional values
const kcal = getNutrientValue("Energiaväärtus (kcal)");
const fat = getNutrientValue("Rasvad");
const satFat = getNutrientValue("küllastunud rasvhapped"); // "millest küllastunud rasvhapped (g)"
const carbs = getNutrientValue("Süsivesikud");
const sugar = getNutrientValue("suhkrud"); // "millest suhkrud (g)"
const protein = getNutrientValue("Valgud");
const salt = getNutrientValue("Sool");
// Combine for Excel pasting (Columns: Name, Kcal, Fats, Sat.Fats, Carbs, Sugars, Protein, Salt)
clipboard += `\t${kcal}\t${fat}\t${satFat}\t${carbs}\t${sugar}\t${protein}\t${salt}`;
// Final clean up
clipboard = clipboard.trim();
if (clipboard) {
GM_setClipboard(clipboard);
console.log("📋 Copied to clipboard:", clipboard);
// Optional visual confirmation, you can uncomment the next line if you want an alert
// alert(`Copied to clipboard!\n\n${title} - ${kcal} kcal`);
}
}, 800); // 800ms delay to ensure the data has safely loaded on the page
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment