Size
6.6 KB
Version
1.0.1
Created
Feb 10, 2026
Updated
about 1 month ago
1// ==UserScript==
2// @name Uber Eats Menu Downloader
3// @description A new extension
4// @version 1.0.1
5// @match https://*.ubereats.com/*
6// @icon https://www.ubereats.com/_static/d526ae562360062f.ico
7// ==/UserScript==
8(function() {
9 'use strict';
10
11 console.log('Uber Eats Menu Downloader initialized');
12
13 // Function to extract menu items from the page
14 function extractMenuItems() {
15 console.log('Starting menu extraction...');
16 const menuItems = [];
17
18 // Find all menu item containers
19 const itemElements = document.querySelectorAll('li[data-testid^="store-item-"]');
20 console.log(`Found ${itemElements.length} menu items`);
21
22 itemElements.forEach((item, index) => {
23 try {
24 // Extract item name
25 const nameElement = item.querySelector('h3[data-testid=""] span, h4[data-testid=""] span');
26 const name = nameElement ? nameElement.textContent.trim() : 'Unknown Item';
27
28 // Extract description
29 const descElement = item.querySelector('div[data-testid=""] span._vy');
30 const description = descElement ? descElement.textContent.trim() : 'No description available';
31
32 // Extract price
33 const priceElement = item.querySelector('div[data-testid=""] span');
34 let price = 'Price not available';
35
36 // Look for price in various possible locations
37 const allSpans = item.querySelectorAll('span');
38 for (const span of allSpans) {
39 const text = span.textContent.trim();
40 // Check if text contains currency symbols or price patterns
41 if (text.match(/KSh|Ksh|\$|€|£|\d+\.\d{2}/) && !text.includes('Get') && text.length < 20) {
42 price = text;
43 break;
44 }
45 }
46
47 console.log(`Item ${index + 1}: ${name} - ${price}`);
48
49 menuItems.push({
50 name: name,
51 description: description,
52 price: price
53 });
54 } catch (error) {
55 console.error(`Error extracting item ${index}:`, error);
56 }
57 });
58
59 return menuItems;
60 }
61
62 // Function to generate downloadable content
63 function generateMenuFile(menuItems) {
64 console.log('Generating menu file...');
65
66 // Get restaurant name from page
67 const restaurantNameElement = document.querySelector('h1[data-testid=""] span, h1 span');
68 const restaurantName = restaurantNameElement ? restaurantNameElement.textContent.trim() : 'Restaurant Menu';
69
70 // Create formatted text content
71 let content = `${restaurantName}\n`;
72 content += `Menu Downloaded: ${new Date().toLocaleString()}\n`;
73 content += `${'='.repeat(60)}\n\n`;
74
75 menuItems.forEach((item, index) => {
76 content += `${index + 1}. ${item.name}\n`;
77 content += ` Price: ${item.price}\n`;
78 content += ` Description: ${item.description}\n\n`;
79 });
80
81 return content;
82 }
83
84 // Function to download the menu
85 function downloadMenu() {
86 console.log('Download button clicked');
87
88 const menuItems = extractMenuItems();
89
90 if (menuItems.length === 0) {
91 alert('No menu items found. Please make sure the page is fully loaded.');
92 return;
93 }
94
95 const content = generateMenuFile(menuItems);
96
97 // Create blob and download
98 const blob = new Blob([content], { type: 'text/plain' });
99 const url = URL.createObjectURL(blob);
100 const a = document.createElement('a');
101 a.href = url;
102 a.download = `ubereats-menu-${Date.now()}.txt`;
103 document.body.appendChild(a);
104 a.click();
105 document.body.removeChild(a);
106 URL.revokeObjectURL(url);
107
108 console.log(`Menu downloaded with ${menuItems.length} items`);
109 alert(`Menu downloaded successfully with ${menuItems.length} items!`);
110 }
111
112 // Function to create and add the download button
113 function addDownloadButton() {
114 console.log('Adding download button...');
115
116 // Check if button already exists
117 if (document.getElementById('ubereats-menu-download-btn')) {
118 console.log('Download button already exists');
119 return;
120 }
121
122 // Create button
123 const button = document.createElement('button');
124 button.id = 'ubereats-menu-download-btn';
125 button.textContent = '📥 Download Menu';
126 button.style.cssText = `
127 position: fixed;
128 top: 20px;
129 right: 20px;
130 z-index: 10000;
131 padding: 12px 20px;
132 background-color: #06C167;
133 color: white;
134 border: none;
135 border-radius: 8px;
136 font-size: 16px;
137 font-weight: 600;
138 cursor: pointer;
139 box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
140 transition: all 0.3s ease;
141 `;
142
143 // Add hover effect
144 button.onmouseover = () => {
145 button.style.backgroundColor = '#05A857';
146 button.style.transform = 'scale(1.05)';
147 };
148 button.onmouseout = () => {
149 button.style.backgroundColor = '#06C167';
150 button.style.transform = 'scale(1)';
151 };
152
153 // Add click handler
154 button.onclick = downloadMenu;
155
156 // Add button to page
157 document.body.appendChild(button);
158 console.log('Download button added successfully');
159 }
160
161 // Initialize the extension
162 function init() {
163 console.log('Initializing Uber Eats Menu Downloader...');
164
165 // Wait for page to load
166 if (document.readyState === 'loading') {
167 document.addEventListener('DOMContentLoaded', init);
168 return;
169 }
170
171 // Add button after a short delay to ensure page is ready
172 setTimeout(() => {
173 addDownloadButton();
174 }, 2000);
175
176 // Re-add button if page content changes (for SPA navigation)
177 const observer = new MutationObserver(() => {
178 if (!document.getElementById('ubereats-menu-download-btn')) {
179 addDownloadButton();
180 }
181 });
182
183 observer.observe(document.body, {
184 childList: true,
185 subtree: true
186 });
187 }
188
189 // Start the extension
190 init();
191})();