Skip to content

Instantly share code, notes, and snippets.

@half2me
Last active November 28, 2019 15:46
Show Gist options
  • Save half2me/e6a070a97c440f44ddd80569037fd503 to your computer and use it in GitHub Desktop.
Save half2me/e6a070a97c440f44ddd80569037fd503 to your computer and use it in GitHub Desktop.
Remove cloudberries from Nespresso
// ==UserScript==
// @name No Cloudberry
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove cloudberry from Nespresso!
// @author h@lfto.me
// @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);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment