Skip to content

Instantly share code, notes, and snippets.

@SamSamskies
Created August 17, 2024 02:10
Show Gist options
  • Save SamSamskies/e778e2d7e99bf4cc25c8281e29ed01d7 to your computer and use it in GitHub Desktop.
Save SamSamskies/e778e2d7e99bf4cc25c8281e29ed01d7 to your computer and use it in GitHub Desktop.
Override WebLN sendPayment
window.webln.sendPayment = (invoice) => fetch(`https://api.qrserver.com/v1/create-qr-code/?data=${invoice}&size=400x400&margin=15`)
.then(response => response.blob())
.then(blob => {
const qrCodeUrl = URL.createObjectURL(blob);
const modal = document.createElement('div');
modal.style.position = 'fixed';
modal.style.top = '0';
modal.style.left = '0';
modal.style.width = '100%';
modal.style.height = '100%';
modal.style.background = 'rgba(0, 0, 0, 0.5)';
modal.style.display = 'flex';
modal.style.justifyContent = 'center';
modal.style.alignItems = 'center';
const img = document.createElement('img');
img.src = qrCodeUrl;
img.style.width = '400px';
img.style.height = '400px';
modal.appendChild(img);
document.body.appendChild(modal);
modal.onclick = () => {
modal.remove();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment