// ==UserScript== // @name Gumroad Region Lock Bypass on free items // @namespace DisableGumroadRegionLock // @version 0.2 // @description Disable gumroad.com Region Lock // @author Samu // @match https://*.gumroad.com/l/* // @grant none // @run-at document-end // @downloadURL none // ==/UserScript== (function() { 'use strict'; function init() { var container = document.querySelector(".i-want-this-container"); var btn = container?.querySelector("button.primary"); var priceInp = container?.querySelector("fieldset.pay-what-you-want-selection"); var warningContainer = container?.querySelector(".warning[role='alert']"); var productId = document.head.querySelector("meta[content][property='product:retailer_item_id']"); var productPrice = document.head.querySelector("meta[content][property='product:price:amount']"); // try restoring buttons if (btn != undefined && false) { // var interval = setInterval(() => { // if (container?.querySelector(".warning[role='alert']")) { // container.insertBefore(btn, container.firstChild); // container.insertBefore(priceInp, container.firstChild); // clearInterval(interval); // } // }, 100); // try getting content url from request } else if (warningContainer != undefined && productId?.content && productPrice?.content === "0.0") { createCustomButton(productId.content, warningContainer); } else { setTimeout(init, 100); } } init(); function createCustomButton(id, container) { var url = "https://" + window.location.host + "/purchases"; var button = document.createElement("button"); button.classList.add("primary"); button.textContent = "View Content"; var errorMsg = "UserScript (Gumroad Region Lock Bypass): Could not fetch contentUrl, script might need update"; button.addEventListener("click", () => { fetchContentUrl(url, id) .then(contentUrl => { if (contentUrl) { window.open(contentUrl, '_blank'); } else { alert(errorMsg); } }) .catch(e => alert(errorMsg)); }); container.innerHTML = ""; container.appendChild(button); } function fetchContentUrl(url, id) { var randomString = (Math.random() + 1).toString(36).substring(2); return fetch(url, { method: "POST", body: new URLSearchParams({ 'line_items[0][permalink]': id, 'line_items[0][perceived_price_cents]': 0, 'email': `${randomString}@${randomString}.com`, }), headers: { "Content-Type": "application/x-www-form-urlencoded", } }) .then(res => res.json()) .then(res => { if (res?.success) { var content = res["line_items"][""]; if (content?.success) { return content["content_url"]; } } return null; }); } //GM_addStyle(".i-want-this-container { display: block !important; }"); })();