Foodora - Highlight items (EN|FI|+)

Highlight items on Foodora (fantasy / fantasia highlighted by default) (EN|FI|+)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Foodora - Highlight items (EN|FI|+)
// @namespace    1N07
// @version      0.4.2
// @description  Highlight items on Foodora (fantasy / fantasia highlighted by default) (EN|FI|+)
// @author       1N07
// @license      unlicense
// @match        https://www.foodora.fi/*restaurant/*
// @match        https://www.foodora.se/*restaurant/*
// @match        https://www.foodora.no/*restaurant/*
// @match        https://www.foodora.hu/*restaurant/*
// @match        https://www.foodora.cz/*restaurant/*
// @match        https://www.foodora.at/*restaurant/*
// @icon         https://www.google.com/s2/favicons?domain=foodora.fi
// @compatible   firefox Only tested on Firefox with Tampermonkey, but should probably work on pretty much all browsers and script managers
// @compatible   chrome Only tested on Firefox with Tampermonkey, but should probably work on pretty much all browsers and script managers
// @compatible   opera Only tested on Firefox with Tampermonkey, but should probably work on pretty much all browsers and script managers
// @compatible   edge Only tested on Firefox with Tampermonkey, but should probably work on pretty much all browsers and script managers
// @compatible   safari Only tested on Firefox with Tampermonkey, but should probably work on pretty much all browsers and script managers
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    //Note, names are not case sensitive
    var names = [
        "my choice",
        "your choice",
        "fantasy",
        "oma valinta",
        "kuten haluatte",
        "fantasia"
    ];

    setInterval(CheckForOmaValinta, 200);

    function CheckForOmaValinta() {
        let found = document.querySelectorAll("[data-testid='menu-product-name']:not(.highlight-checked)");
        for(let i = 0; i < found.length; i++)
        {
            found[i].classList.add("highlight-checked");
            for(let j = 0; j < names.length; j++)
            {
                if(found[i].innerHTML.toLowerCase().includes(names[j].toLowerCase()))
                {
                    let target = found[i];
                    while(!target.classList.contains('product-tile'))
                        target = target.parentNode;
                    target = target.getElementsByClassName("product-tile__animation-overlay")[0];
                    target.style.backgroundColor = "rgba(112, 255, 60, 0.33)";
                    j = names.length; //break inner loop
                }
            }
        }
    }
})();