Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Opera Extensions Documentation Outdated: For Manifest v2 instead of v3 #646

Open
SimonEData opened this issue Jul 31, 2023 · 1 comment
Open

Comments

@SimonEData
Copy link

I tried following the instructions for creating a sample Opera extension at https://dev.opera.com/extensions/basics/. This seems to correspond with the basics.md file in the _extensions src folder, https://github.com/operasoftware/devopera/blob/master/src/_extensions/basics.md. The instructions are for creating a v2-style manifest with a background script.

When I clicked the "Load Unpacked" button on the Opera Extensions page I got the following error:

Manifest version 2 is deprecated, and support will be removed in 2023. See https://developer.chrome.com/blog/mv2-transition/ for more details.

Simply changing the manifest_version in the manifest file from 2 to 3 was not enough to resolve the issue. Apparently, the background.scripts array has been replaced by a background.service_worker object. And making that change wasn't sufficient to get it working either, I assume because there is a fundamental difference between a background script in v2 and a background service worker in v3.

Please update the Opera extension documentation to reflect the changes from manifest v2 to v3. This should apply not just to the basics.md file but also to any other references to the manifest and to anything else that has changed between v2 and v3 (eg the description of background processes in the architecture-overview.md and getting-started.md files).

@SimonEData
Copy link
Author

After looking into the Chrome documentation about migrating to Manifest V3, https://developer.chrome.com/docs/extensions/migrating/, I was able to modify the manifest file and the background script to get them working. I suggest changing the code in the basics page as follows:

  1. The Manifest file. Note the manifest_version is 3, background.service_worker has replaced background.scripts (and it's a single object, not an array), and action has replaced browser_action:
{
	"manifest_version": 3,

	"name": "Opera Extensions — Getting Started",
	"description": "Sample extension for the “Making your first extension” article",
	"version": "1.0",
	"background": {
		"service_worker": "service-worker.js"
	},

	"permissions": ["tabs"],
	"action": {
		"default_icon": "icon.png",
		"default_title": "Go to Dev.Opera!"
	}
}
  1. Rename the background.js file to service-worker.js and change the code to replace chrome.browserAction... with chrome.action... :
chrome.action.onClicked.addListener(function() {
	chrome.tabs.query({
		currentWindow: true,
		active: true
	}, function(tab) {
		chrome.tabs.create({
			"url": "http://dev.opera.com"
		});
	});
});

I also suggest adding a note about how to display the icon on the toolbar by pinning it via the Extensions button. As someone brand new to extensions I assumed the icon wasn't displaying because there was a problem in my extension manifest or code. I eventually discovered icons aren't displayed by default. I think a couple of sentences explaining this could avoid a lot of angst among newbies like me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant