Add to Cookidoo (Bypass Country Restrictions)

Bypass "Add to cookidoo" button geography restrictions

目前為 2023-12-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Add to Cookidoo (Bypass Country Restrictions)
// @namespace    http://your-namespace-here
// @version      1.0
// @description  Bypass "Add to cookidoo" button geography restrictions
// @author       momo
// @match        *://www.recipecommunity.com.au/*
// @match        *://www.rezeptwelt.de/*
// @match        *://www.mundodereceitasbimby.com.pt/*
// @match        *://www.espace-recettes.fr/*
// @match        *://www.recetario.es/*
// @match        *://www.svetreceptu.cz/*
// @match        *://www.ricettario-bimby.it/*
// @match        *://www.przepisownia.pl/*
// @license     Mozilla Public License 2.0
// ==/UserScript==

(function() {
    'use strict';

      // modify if you're in another country and want to use your version of cookidoo:
      const myCookidooURL = 'cookidoo.thermomix.com'
      const myCountryCode = 'en-US'
      const myCookidooCountry = 'US'

      const domainMappings = {
          'www.recipecommunity.com.au': {
              cookidooLink: 'cookidoo.com.au',
              countryCode: 'en-AU',
          },
          'www.rezeptwelt.de': {
              cookidooLink: 'cookidoo.de',
              countryCode: 'de-DE',
          },
          'www.mundodereceitasbimby.com.pt': {
              cookidooLink: 'cookidoo.pt',
              countryCode: 'pt-PT',
          },
          'www.espace-recettes.fr': {
              cookidooLink: 'cookidoo.fr',
              countryCode: 'fr-FR',
          },
          'www.recetario.es': {
              cookidooLink: 'cookidoo.es',
              countryCode: 'es-ES',
          },
          'www.svetreceptu.cz': {
              cookidooLink: 'cookidoo.cz',
              countryCode: 'cz-CZ',
          },
          'www.ricettario-bimby.it': {
              cookidooLink: 'cookidoo.it',
              countryCode: 'it-IT',
          },
          'www.przepisownia.pl': {
              cookidooLink: 'cookidoo.pl',
              countryCode: 'pl-PL',
          }
      };

    // Wait for the page to fully load
    window.addEventListener('load', function () {
        const currentDomain = window.location.hostname;

        GM_log(currentDomain);

        // Select the host element containing the shadow root
        const hostElement = document.querySelector(`add-to-cookidoo[market="${domainMappings[currentDomain].cookidooLink}"]`);

        if (hostElement) {
            // Access the shadow root
            const shadowRoot = hostElement.shadowRoot;

            if (shadowRoot) {
                // Use querySelector to select the green button within the shadow DOM
                const button = shadowRoot.querySelector('a.theme-green.type-single-line.font-size-default.padding-default.corner-square.text-container');

                if (button) {
                    // Get the modified href from the green button within the Shadow DOM
                    let modifiedHref = button.getAttribute('href');

                    // Replace the domain and change 'en-AU' to 'en-US' in the modifiedHref
                    modifiedHref = modifiedHref.replace(domainMappings[currentDomain].cookidooLink, myCookidooURL);
                    modifiedHref = modifiedHref.replace(domainMappings[currentDomain].countryCode, myCountryCode);

                    // Create the "Add to Cookidoo US" button element
                    const addButton = document.createElement('a');
                    addButton.setAttribute('href', modifiedHref);
                    addButton.setAttribute('target', '_blank');
                    addButton.style.position = 'fixed';
                    addButton.style.bottom = '20px';
                    addButton.style.left = '20px';
                    addButton.style.backgroundColor = 'green'; // You can change the button's color
                    addButton.style.color = 'white';
                    addButton.style.padding = '10px 20px';
                    addButton.style.borderRadius = '5px';
                    addButton.style.fontSize = '25px';
                    addButton.style.zIndex = '9999';
                    addButton.textContent = 'Add to Cookidoo ' + myCookidooCountry;

                    // Append the "Add to Cookidoo US" button to the document body
                    document.body.appendChild(addButton);
                }
            }
        }
    });
})();