I’m trying to update the content of a sidebar but I cannot set it’s content from a background script. How can I do this? Is this possible?
Thank you
I’m trying to update the content of a sidebar but I cannot set it’s content from a background script. How can I do this? Is this possible?
Thank you
Aaaaa… I misunderstood the API. I thought that I can only set an existing hardcoded file but I can set any dom element I want in the setPanel fucntion, right? Will try that when I will get home. Thank you again for your help @freaktechnik
I think you can also use blob and data URIs, yes. Else you’ll have to use a blank html file of your extension with a script that inserts whatever you want.
browser.sidebarAction.setPanel({panel: 'data:text/html,lots of text...<p><a name%3D"bottom">bottom</a>?arg=val'});
I get this
Error: Access denied for URL data:text/html,lots of text...<p><a name%3D"bottom">bottom</a>?arg=val
also… background js
browser.runtime.sendMessage({"url": 'value'});
sidebar.html
<script>
function handleMessage(request, sender, sendResponse) {
document.getElementById("myElement").innerHTML = 'test';
}
browser.runtime.onMessage.addListener(handleMessage);
</script>
</head>
<body>
<div id="myElement">This is an awesome certificate info!</div>
Error: Could not establish connection. Receiving end does not exist.
That should definitely work. Though I’d suggest doing communication the other way around and sending a response from the background script.
I have a context menu that triggers this… the context menu item and listeners are in the background script.
I made my addon public! Uuuhuuu! Still uses an ugly alert as an UI. If you have a better proposal I’m all ears