const button = new DOMParser().parseFromString( '', 'text/html' ).body.firstElementChild; button.addEventListener('click', function () { chrome.runtime.sendMessage({ type: 'open_side_panel' }); }); document.body.append(button);