Berry Blocker

Remove cloudberry from the Nespresso site

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Berry Blocker
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Remove cloudberry from the Nespresso site
// @author       [email protected]
// @match        *://www.nespresso.com/*/order/capsules/original
// @match        *://www.nespresso.com/*/home
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let handle;
    let tries = 20;

    const removeCloudBerry = () => {
        let success = false;
        tries--;
        if (tries <= 0) {
            clearInterval(handle);
            console.log("I can't find any cloudberries here...");
        }

        let berries = [
            { selector: 'article[data-product-code="7550.40"]', up: 1 },
            { selector: 'img[alt="Nordic Cloudberry Variation"]', up: 5 },
        ];

        berries.forEach(({ selector, up = 0 }) => {
            let ele = document.querySelector(selector);
            if (ele) {
                for (let i=0; i<up; i++) {
                    if (ele.parentNode) {
                        ele = ele.parentNode;
                    } else {
                        break;
                    }
                }

                ele.style.display = 'none'; // hide that nasty element
                console.log("I've hidden one of those nasty cloudberries");
                success = true;
            }
        });

        if (success) {
            console.log("I've gotten rid of the cloudberries, my job here is done.");
            clearInterval(handle);
        }
    };

    handle = setInterval(removeCloudBerry, 500);
})();