Hi Hans, thank you so much for your help. I really apologize for my careless mistakes in the first post. I realize that I didn’t do a very good job with the code formatting, etc.
My manifest.json file contains the following relevant code:
"sidebar_action": {
"browser_style": false,
"default_icon": "/icons/context-search.svg",
"default_title": "Search results",
"default_panel": "/sidebar/search_results.html",
"open_at_install": false
},
...
"permissions": [
"activeTab",
"contextMenus",
"storage",
"search",
"clipboardWrite",
"webRequest",
"webRequestBlocking"
],
My background script contains a searchUsing() function that opens the sidebar and sets the panel to the targetUrl corresponding to a search query for the chosen search engine:
function searchUsing(id, tabIndex) {
const searchEngineUrl = searchEngines[id].url;
targetUrl = getSearchEngineUrl(searchEngineUrl, selection);
if (logToConsole) console.log(`Target url: ${targetUrl}`);
if (contextsearch_openSearchResultsInSidebar) {
browser.sidebarAction.setPanel({ panel: targetUrl });
browser.sidebarAction.setTitle({ title: 'Search results' });
return;
}
displaySearchResults(targetUrl, tabIndex);
}
It turns out that I was missing the “<all_urls>” permission. It’s looking much better now, although Google search results are a bit of a mixed bag with some content overflowing horizontally. I have to use the “<all_urls>” permission because I don’t know in advance which custom search engines users might want to use.
I’m most grateful to you, Hans, for spotting this silly mistake!
I found the extension created by Mozilla that works nicely to view web pages in mobile view in the sidebar: it’s called Side View and I don’t think that its listed in the web extension examples.
Do I need to keep a sidebar_action in my manifest? I’m not using the search_results.html as I’m always using the setPanel method.
Also, is it possible to style the sidebar panel with CSS rules dynamically? Currently, my search_results.css stylesheet is used for search_results.html which isn’t being used.
Thank you again. I wish you a great end of week and I’m sorry if I came across as being a bit aggressive.
P.S. I don’t seem to be formatting my code correctly in these posts. Need to look this up somewhere! Sorry!