Created
June 7, 2023 20:40
-
-
Save thebells1111/cdd732a52cb5314a0434efd61391f5a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script | |
src="https://unpkg.com/webln@0.3.2/dist/webln.min.js" | |
integrity="sha384-MpjpvOQqXz9nCoLUS/sR0bhLwGYuNPMOBN50jsqhnqAzDq0GiOI0u6oC5fHitzI2" | |
crossorigin="anonymous" | |
></script> | |
<style> | |
#boost, | |
#install-alby { | |
display: none; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="content"> | |
<button id="boost">Boost</button> | |
<p id="install-alby">Install Alby to Support</p> | |
</div> | |
<script> | |
const boostButton = document.getElementById("boost"); | |
const installParagraph = document.getElementById("install-alby"); | |
if (typeof window.WebLN !== "undefined") { | |
boostButton.style.display = "block"; | |
boostButton.addEventListener("click", handleBoost); | |
} else { | |
installParagraph.style.display = "block"; | |
} | |
async function handleBoost() { | |
try { | |
const webln = await WebLN.requestProvider(); | |
await webln.keysend({ | |
destination: | |
"030a58b8653d32b99200a2334cfe913e51dc7d155aa0116c176657a4f1722677a3", | |
amount: 100, | |
customRecords: { 696969: "2yjUCncyVMyWY31einuk" }, | |
}); | |
} catch (err) { | |
installParagraph.style.display = "block"; | |
boostButton.style.display = "none"; | |
alert(err.message); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment