Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically open a Chrome plugin's options.html page?

Is there a way to open a Google Chrome plugin's options.html page via Javascript in background.html?

like image 424
davidscolgan Avatar asked Jul 21 '11 20:07

davidscolgan


People also ask

How do you code Chrome extensions in Python?

The idea is to compile Python to Javascript (technically a JS pre-compiler) using Rapydscript. Then include the generated script in the Chrome extension. The site above has a zip file with all the stuff inside. I recommend using Rapydscript instead of Pyjamas.

How do I show a pop up extension in Chrome?

In browser action, you should include default_popup value which points to the HTML file to be rendered as popup. In your case it is userinfo. html. You should look into setPopup method and chrome.

Can you build a Chrome extension with Python?

Chrome plugins are created using HTML, JavaScript and CSS. We can use Python to create normal Chrome extensions using a Python to Javascript compiler (Rapydscript).


2 Answers

There is a new method that is enabled beginning with Chrome 42:

chrome.runtime.openOptionsPage(function callback)

Open your Extension's options page, if possible.

The precise behavior may depend on your manifest's options_ui or options_page key, or what Chrome happens to support at the time. For example, the page may be opened in a new tab, within chrome://extensions, within an App, or it may just focus an open options page. It will never cause the caller page to reload.

If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set lastError.

like image 53
Xan Avatar answered Sep 28 '22 13:09

Xan


chrome.tabs.create({ url: "options.html" }); 

Update

Starting with version 40, Chrome now uses a new popup options dialog from the extension management page instead of dedicated options pages (which are being deprecated). You can still achieve the same effect with a modification to the URL.

chrome.tabs.create({ 'url': 'chrome://extensions/?options=' + chrome.runtime.id }); 
like image 21
serg Avatar answered Sep 28 '22 11:09

serg