I want to migrate a Chrome manifest v2 extension to v3 and thus need to update several API calls.
Google's instruction on how to migrate to v3 lists at the bottom a bunch of deprecated APIs, however the guide ends there and doesn't mention or link a reference that lays out which deprecated API was replaced by which new API. I haven't found info on this anywhere else either - any ideas?
For example one of the listed APIs is chrome.extension.getURL()
, which is used a lot by my extension. But I couldn't find how to update it so that I am able to migrate to v3.
CodePudding user response:
Here the new Chrome extension API for manifest v3:
chrome.extension.sendRequest() => chrome.runtime.sendMessage()
chrome.extension.onRequest => chrome.runtime.onMessage
chrome.extension.onRequestExternal => chrome.runtime.onMessageExternal
chrome.extension.lastError => chrome.runtime.lastError
chrome.extension.getURL() => chrome.runtime.getUrl()
chrome.extension.getExtensionTabs() => chrome.extension.getViews()
chrome.tabs.Tab.selected => chrome.tabs.query({active: true})
chrome.tabs.sendRequest() => chrome.runtime.runtime.sendMessage()
chrome.tabs.getSelected() => chrome.tabs.query({active: true})
chrome.tabs.getAllInWindow() => chrome.tabs.query({currentWindow: true})
chrome.tabs.onSelectionChanged => chrome.tabs.onActivated()
chrome.tabs.onActiveChanged => chrome.tabs.onActivated()
chrome.tabs.onHighlightChanged => chrome.tabs.onHighlighted
As well as the undocumented:
chrome.extension.sendMessage() => chrome.runtime.sendMessage()
chrome.extension.connect() => chrome.runtime.connect()
chrome.extension.onConnect => chrome.runtime.onConnect
chrome.extension.onMessage => chrome.runtime.onMessage