Add to Cookidoo (Bypass Country Restrictions)

Bypass "Add to cookidoo" button geography restrictions

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

  1. // ==UserScript==
  2. // @name Add to Cookidoo (Bypass Country Restrictions)
  3. // @namespace http://your-namespace-here
  4. // @version 1.0
  5. // @description Bypass "Add to cookidoo" button geography restrictions
  6. // @author momo
  7. // @match *://www.recipecommunity.com.au/*
  8. // @match *://www.rezeptwelt.de/*
  9. // @match *://www.mundodereceitasbimby.com.pt/*
  10. // @match *://www.espace-recettes.fr/*
  11. // @match *://www.recetario.es/*
  12. // @match *://www.svetreceptu.cz/*
  13. // @match *://www.ricettario-bimby.it/*
  14. // @match *://www.przepisownia.pl/*
  15. // @license Mozilla Public License 2.0
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. // modify if you're in another country and want to use your version of cookidoo:
  22. const myCookidooURL = 'cookidoo.thermomix.com'
  23. const myCountryCode = 'en-US'
  24. const myCookidooCountry = 'US'
  25.  
  26. const domainMappings = {
  27. 'www.recipecommunity.com.au': {
  28. cookidooLink: 'cookidoo.com.au',
  29. countryCode: 'en-AU',
  30. },
  31. 'www.rezeptwelt.de': {
  32. cookidooLink: 'cookidoo.de',
  33. countryCode: 'de-DE',
  34. },
  35. 'www.mundodereceitasbimby.com.pt': {
  36. cookidooLink: 'cookidoo.pt',
  37. countryCode: 'pt-PT',
  38. },
  39. 'www.espace-recettes.fr': {
  40. cookidooLink: 'cookidoo.fr',
  41. countryCode: 'fr-FR',
  42. },
  43. 'www.recetario.es': {
  44. cookidooLink: 'cookidoo.es',
  45. countryCode: 'es-ES',
  46. },
  47. 'www.svetreceptu.cz': {
  48. cookidooLink: 'cookidoo.cz',
  49. countryCode: 'cz-CZ',
  50. },
  51. 'www.ricettario-bimby.it': {
  52. cookidooLink: 'cookidoo.it',
  53. countryCode: 'it-IT',
  54. },
  55. 'www.przepisownia.pl': {
  56. cookidooLink: 'cookidoo.pl',
  57. countryCode: 'pl-PL',
  58. }
  59. };
  60.  
  61. // Wait for the page to fully load
  62. window.addEventListener('load', function () {
  63. const currentDomain = window.location.hostname;
  64.  
  65. GM_log(currentDomain);
  66.  
  67. // Select the host element containing the shadow root
  68. const hostElement = document.querySelector(`add-to-cookidoo[market="${domainMappings[currentDomain].cookidooLink}"]`);
  69.  
  70. if (hostElement) {
  71. // Access the shadow root
  72. const shadowRoot = hostElement.shadowRoot;
  73.  
  74. if (shadowRoot) {
  75. // Use querySelector to select the green button within the shadow DOM
  76. const button = shadowRoot.querySelector('a.theme-green.type-single-line.font-size-default.padding-default.corner-square.text-container');
  77.  
  78. if (button) {
  79. // Get the modified href from the green button within the Shadow DOM
  80. let modifiedHref = button.getAttribute('href');
  81.  
  82. // Replace the domain and change 'en-AU' to 'en-US' in the modifiedHref
  83. modifiedHref = modifiedHref.replace(domainMappings[currentDomain].cookidooLink, myCookidooURL);
  84. modifiedHref = modifiedHref.replace(domainMappings[currentDomain].countryCode, myCountryCode);
  85.  
  86. // Create the "Add to Cookidoo US" button element
  87. const addButton = document.createElement('a');
  88. addButton.setAttribute('href', modifiedHref);
  89. addButton.setAttribute('target', '_blank');
  90. addButton.style.position = 'fixed';
  91. addButton.style.bottom = '20px';
  92. addButton.style.left = '20px';
  93. addButton.style.backgroundColor = 'green'; // You can change the button's color
  94. addButton.style.color = 'white';
  95. addButton.style.padding = '10px 20px';
  96. addButton.style.borderRadius = '5px';
  97. addButton.style.fontSize = '25px';
  98. addButton.style.zIndex = '9999';
  99. addButton.textContent = 'Add to Cookidoo ' + myCookidooCountry;
  100.  
  101. // Append the "Add to Cookidoo US" button to the document body
  102. document.body.appendChild(addButton);
  103. }
  104. }
  105. }
  106. });
  107. })();