Add to Cookidoo (Bypass Country Restrictions)

Bypass "Add to cookidoo" button geography restrictions

当前为 2023-12-02 提交的版本,查看 最新版本

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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);
                }
            }
        }
    });
})();