85 lines
2.5 KiB
JavaScript
85 lines
2.5 KiB
JavaScript
// ==UserScript==
|
|
// @name Cursor Enterprise Invoice/SEPA Mock
|
|
// @namespace gothbreach.cursor.invoice
|
|
// @version 1.0.0
|
|
// @description Mock Cursor tRPC billing endpoints to force enterprise invoice/SEPA flow
|
|
// @match *://cursor.com/*
|
|
// @run-at document-start
|
|
// @grant none
|
|
// ==/UserScript==
|
|
|
|
(function () {
|
|
"use strict";
|
|
|
|
const BILLING_PATTERNS = [
|
|
'/api/trpc/billing',
|
|
'/api/trpc/checkout',
|
|
'/api/billing/'
|
|
];
|
|
|
|
const MOCK_DATA = {
|
|
paymentMethods: ['invoice', 'sepa', 'wire_transfer', 'bank_transfer'],
|
|
checkoutFlow: 'enterprise',
|
|
invoiceBilling: { enabled: true, currency: 'eur' },
|
|
sepaAvailable: true,
|
|
bankTransferAvailable: true,
|
|
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('[Cursor SEPA] Original:', JSON.stringify(data).substring(0, 300));
|
|
|
|
// tRPC wraps response in { result: { data: ... } }
|
|
const mock = {
|
|
...data,
|
|
result: {
|
|
data: {
|
|
...(data?.result?.data || {}),
|
|
...MOCK_DATA
|
|
}
|
|
}
|
|
};
|
|
|
|
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('cursor-sepa-badge')) return;
|
|
const badge = document.createElement('div');
|
|
badge.id = 'cursor-sepa-badge';
|
|
badge.textContent = 'Cursor SEPA 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('[Cursor SEPA] Script loaded:', location.href);
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', showBadge, { once: true });
|
|
} else {
|
|
showBadge();
|
|
}
|
|
})(); |