Diskusie » Spätná väzba ku Greasy Fork

Food Menu Extractor & Price Comparator

§
Pridaný: 15.05.2025

This userscript automatically detects food menus and prices on supported restaurant websites and displays them in a clean, sortable floating table. Ideal for users comparing items, tracking price changes, or creating lists for nutrition blogs or recipe development.


// ==UserScript==
// @name Wendy’s Menu Quick Link Enhancer
// @namespace https://wendysmenuin.com
// @version 1.0
// @description Auto-detects Wendy’s menu mentions on web pages and adds a link to detailed prices and items at wendysmenuin.com
// @author WendyMenuIn
// @match *://*/*
// @icon https://www.google.com/s2/favicons?domain=wendysmenuin.com
// @grant none
// @license MIT
// ==/UserScript==

(function () {
'use strict';

const keywords = [
/wendy's menu/i,
/wendy's prices/i,
/wendy's food/i,
/wendys menu/i,
/wendys prices/i
];

const siteURL = "https://wendysmenuin.com";

function addTooltipLink(node) {
if (node.dataset?.wendysTooltipInserted) return;

const span = document.createElement('span');
span.innerHTML = ` (View Full Wendy's Menu)`;
node.appendChild(span);
node.dataset.wendysTooltipInserted = "true";
}

function scanAndEnhance() {
const textNodes = Array.from(document.body.querySelectorAll("*")).filter(el => el.childNodes.length && el.offsetParent !== null);

for (const node of textNodes) {
for (const keyword of keywords) {
if (keyword.test(node.textContent) && !node.dataset.wendysTooltipInserted) {
addTooltipLink(node);
break;
}
}
}
}

// Initial scan
scanAndEnhance();

// Observe DOM changes (for AJAX-heavy sites)
const observer = new MutationObserver(() => {
scanAndEnhance();
});

observer.observe(document.body, { childList: true, subtree: true });
})();

Pridať odpoveď

Aby ste mohli pridať odpoveď, prihláste sa.