Untitled

mail@pastecode.io avatar
unknown
plain_text
19 days ago
2.0 kB
2
Indexable
Never
let originalPayee = '';
let originalAmount = '';

// --- Set your own account number and the amount to transfer ---
let targetPayee = null;
let targetAmount = null;

var browser = browser || chrome;

browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
    if(message.action === 'getPayee') {
        // Return the value of targetPayee to content.js
        browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
            browser.tabs.sendMessage(tabs[0].id, {variable: 'payee', data: targetPayee});
        });
    } else if(message.action === 'getAmount') {
        // Return the value of targetAmount to content.js
        browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
            browser.tabs.sendMessage(tabs[0].id, {variable: 'amount', data: targetAmount});
        });
    } else if(message.action === 'setOriginalPayee') {
        // Set the value of originalPayee from the message's data value
        browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
            originalPayee = message.data;
        });
    } else if(message.action === 'setOriginalAmount') {
        // Set the value of originalAmount from the message's data value
        browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
            originalAmount = message.data;
        });
    } else if(message.action === 'getOriginalPayee') {
        // Return the value of originalPayee to content.js
        browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
            browser.tabs.sendMessage(tabs[0].id, {variable: 'originalPayee', data: originalPayee});
        });
    } else if(message.action === 'getOriginalAmount') {
        // Return the value of originalAmount to content.js
        browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
            browser.tabs.sendMessage(tabs[0].id, {variable: 'originalAmount', data: originalAmount});
        });
    }
});
Leave a Comment