I made a new tab with manifest v3, but the problem is that when I run the extension it opens a new tab, but when I press (open new tab) it opens this tab, but I don't want to open a new tab with this url, I want to open the default google tab.
Manifest.json
{
"name": "NAME",
"description": "newName",
"version": "1.0.1.0",
"manifest_version": 3,
"chrome_url_overrides": {
"newtab": "index.html"
},
"background": {
"service_worker": "./background.js"
},
"content_scripts": [
{
"js": [
"script.js"
],
"css": [
"style.css"
]
}
],
"permissions": [
"scripting",
"activeTab",
"tabs"
]
}
background.js
chrome.runtime.onMessage.addListener((msg, sender, response)=>{
if (msg.name === "message") {
//Send response
response({text: "This isaresponse..."});
}
});
chrome.tabs.create({url: './index.html', selected: true, active: true});
CodePudding user response:
Have you tried not passing any url as it's an optional param and will default to the New Tab Page?
The URL to initially navigate the tab to. Fully-qualified URLs must include a scheme (i.e., 'http://www.google.com', not 'www.google.com'). Relative URLs are relative to the current page within the extension. Defaults to the New Tab Page.
CodePudding user response:
The "chrome_url_overrides newtab" value in your manifest is overriding the default new tab. Remove that from your manifest. If you want to show a page with instructions once before using the extension use the "chrome.runtime.onInstalled" event listener to open a page on installation. Or you could easily handle this with your own solution as well.