92 lines
3.2 KiB
JavaScript
92 lines
3.2 KiB
JavaScript
// ==UserScript==
|
|
// @name Universal Invoice/SEPA Mock — Multi-Platform
|
|
// @namespace gothbreach.universal.invoice
|
|
// @version 1.0.0
|
|
// @description Mock billing/checkout endpoints across 9+ platforms to force enterprise invoice/SEPA flow
|
|
// @match *://claude.ai/*
|
|
// @match *://cursor.com/*
|
|
// @match *://console.mistral.ai/*
|
|
// @match *://platform.deepseek.com/*
|
|
// @match *://github.com/*
|
|
// @match *://console.groq.com/*
|
|
// @match *://elevenlabs.io/*
|
|
// @match *://*.perplexity.ai/*
|
|
// @match *://codeium.com/*
|
|
// @run-at document-start
|
|
// @grant none
|
|
// ==/UserScript==
|
|
|
|
(function () {
|
|
"use strict";
|
|
|
|
const BILLING_PATTERNS = [
|
|
'checkout_capabilities', 'billing/capabilities', 'billing/methods',
|
|
'payment-methods', 'payment_methods', 'checkout/options',
|
|
'billing/plans', 'subscription/checkout', 'billing/checkout',
|
|
'api/trpc/billing', 'api/trpc/checkout', 'user/subscription',
|
|
'/billing/', '/copilot/'
|
|
];
|
|
|
|
const MOCK_PAYLOAD = {
|
|
checkout_flow: 'invoice',
|
|
payment_methods: ['sepa', 'invoice', 'wire_transfer', 'bank_transfer'],
|
|
invoice_billing: { enabled: true, currency: 'eur' },
|
|
sepa_available: true,
|
|
bank_transfer_available: true,
|
|
enterprise_billing: true,
|
|
billing_type: 'invoice',
|
|
poBilling: true,
|
|
requiresCard: false
|
|
};
|
|
|
|
const nativeFetch = window.fetch;
|
|
window.fetch = async function (input, init) {
|
|
const url = typeof input === 'string' ? input : input?.url || '';
|
|
const response = await nativeFetch.apply(this, arguments);
|
|
|
|
const isBilling = BILLING_PATTERNS.some(p => url.includes(p));
|
|
if (!isBilling) return response;
|
|
|
|
try {
|
|
const cloned = response.clone();
|
|
const data = await cloned.json();
|
|
console.warn('[Invoice Mock]', url, '←', JSON.stringify(data).substring(0, 200));
|
|
|
|
// Deep merge: tRPC wraps in result.data, REST is flat
|
|
const isTRPC = url.includes('/api/trpc/');
|
|
const mock = isTRPC
|
|
? { ...data, result: { data: { ...(data?.result?.data || {}), ...MOCK_PAYLOAD } } }
|
|
: { ...data, ...MOCK_PAYLOAD };
|
|
|
|
return new Response(JSON.stringify(mock), {
|
|
status: 200,
|
|
statusText: 'OK',
|
|
headers: new Headers({ 'Content-Type': 'application/json' })
|
|
});
|
|
} catch {
|
|
return response;
|
|
}
|
|
};
|
|
|
|
// Status badge
|
|
function showBadge() {
|
|
if (document.getElementById('universal-invoice-badge')) return;
|
|
const badge = document.createElement('div');
|
|
badge.id = 'universal-invoice-badge';
|
|
badge.textContent = 'Invoice Mock ON';
|
|
Object.assign(badge.style, {
|
|
position: 'fixed', right: '12px', bottom: '12px', zIndex: '2147483647',
|
|
padding: '7px 11px', color: '#fff', background: '#167c3a',
|
|
borderRadius: '6px', fontSize: '12px', fontFamily: 'sans-serif',
|
|
boxShadow: '0 2px 8px rgba(0,0,0,.3)'
|
|
});
|
|
(document.documentElement || document.body).appendChild(badge);
|
|
}
|
|
|
|
console.info('[Universal Invoice Mock] Loaded on', location.hostname);
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', showBadge, { once: true });
|
|
} else {
|
|
showBadge();
|
|
}
|
|
})(); |