NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Cookidoo Cleaner // @version 0.4 // @description Clean the content of the cookidoo website to print it nicely // @author Carles Figuerola // @match https://cookidoo.thermomix.com/recipes/recipe/* // @grant GM_addStyle // @copyright 2020, arrowsama (https://openuserjs.org/users/arrowsama) // @license MIT // ==/UserScript== function addGlobalStyle(css) { var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { return; } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style); } function hide_by_class(className){ try { document.getElementsByClassName(className)[0].style.display = 'none'; } catch(err) { unsafeWindow.console.log("Cannot hide class: " + className); } } function hide_by_id(id){ try { document.getElementById(id).style.display = 'none'; } catch(err) { unsafeWindow.console.log("Cannot hide id: " + id); } } function hide_by_tagname(tagName) { try { document.getElementsByTagName(tagName)[0].style.display = 'none'; } catch(err) { unsafeWindow.console.log("Cannot hide tagName: " + tagName); } } function hide_created_recipes_banner() { try { document.querySelectorAll('recipe-cr-promo-banner')[0].style.display = 'none'; } catch(err) { unsafeWindow.console.log("Cannot hide Created Recipes banner"); } } function clean_page() { document.title = document.title.split('-')[0].trim(); // Hide unneded elements hide_by_class("page-header"); document.getElementsByClassName("g-wrapper")[0].style.marginTop = '0em'; hide_by_class("recipe-card__tm-version"); hide_by_class("recipe-card__btn-line"); hide_by_tagname("core-rating"); hide_by_id("additional-categories"); hide_by_id("core-share"); hide_by_id("in-collections"); hide_by_id("alternative-recipes"); hide_by_tagname('core-footer'); hide_by_tagname('core-toast'); hide_created_recipes_banner(); // Add pagebreaks document.getElementsByClassName("g-wrapper")[1].insertAdjacentHTML('afterend','<div class="pagebreak"></div>'); addGlobalStyle('@media print{ .pagebreak {page-break-before: always;}}'); // Print accomodations GM_addStyle( ` .recipe-card__picture img { display: block; min-height: 100%; max-height: 65vw; } ` ); } (function() { 'use strict'; clean_page(); })();