javascriptgoogle-chrome-extensionopera-extension

Can an Options page have a page action in an Opera extension?


I have a Google Chrome extension that I’m wanting to convert to an Opera extension. Part of the functionality is that the options page has a page action.

manifest.json:

{
    "name": "Option Page Action",
    "version": "0",
    "manifest_version": 2,
    "options_page": "options.html",
    "background": { "scripts": [ "background.js" ] },
    "page_action": {}
}

options.html:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="options.js"></script>
</head>
<body>
<p>
I have a page action in Google Chrome, but not in Opera.
</p>
</body>
</html>

options.js:

chrome.runtime.connect();

background.js:

chrome.runtime.onConnect.addListener(function(port) {
    chrome.pageAction.show(port.sender.tab.id);
});

In Chrome, this works fine. In Opera, the page action doesn’t appear. Debugging shows that show(tabId) is called, and doesn’t throw an error. But the page action doesn’t appear. Since Opera extensions are (for these purposes) the same as Chrome extensions, I don’t understand why there’s a difference, and how I can overcome it. Is there a way that I can have a page action on my options page?


Solution

  • Opera does not display the URL of extension pages. This used to happen in Chrome as well (crbug.com/72021), but it had been fixed in Chrome 28. Opera has not applied that patch for some reason.

    If having the page action on the options page is important, you could host the options page on a public website, and use a content script to inject the functionality in that page. You could even use a blank page as a website and insert the HTML & CSS via that content script.