chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { document.getElementById('lastCallDate').textContent = message.date; document.getElementById('result').textContent = message.result; return false; }); document.addEventListener('DOMContentLoaded', function () { // Get last call URL date and result chrome.runtime.sendMessage({ type: 'sendState' }); // Add event listener to call URL button document.getElementById('callURLBtn').addEventListener('click', function () { chrome.runtime.sendMessage({ type: 'callURLManually' }); }); });