Chrome Extension: Set both themes and defaults in single extension - google-chrome

Is it possible to set both chrome themes and chrome defaults (i.e. Default Homepage and Search engine) in single chrome extension?

No, since Themes are separate from Extensions (that have the functionality to override settings) - it cannot be one entity. As soon as you declare "theme" in the manifest, you can't add normal Extension keys.
An extension cannot cause other extensions (including themes) to be installed. I have briefly thought of using Shared Modules mechanism, but that doesn't allow the imported extension to operate normally - so an imported theme (if that was even possible, which I doubt) wouldn't work.
Additionally, there is no extension API to manipulate themes, and no setting override to configure a theme.

Related

How to pre-install a Google Chrome extension

I have created a browser, which relies on an extension to work properly. I have not yet published the extension to the store and would prefer to avoid doing so. Is there a way for me to automatically install or pre-install an extension, to allow for easy distribution along with the actual browser?

Whitelist a CORS policy for a browser extension?

I have a browser extension which POSTs to a server. I want to whitelist the extension's origin in my server. For instance, requests for the Chrome extension originate from a location like: chrome-extension://fjhbdidbplpijoncnlfoadfadfasdf and from Firefox like: moz-extension://cadf4351-e4f3-ca4d-b974-812309843dafd
I realize that I can whitelist those particular addresses on my server, but I'm not sure if they're static addresses. Do these randomly generated locations ever change, like if I ever submit an update? Is there anyway to set them permanently?
Do those change?
Situation differs for Chrome and Firefox.
Chrome
For released extensions that are on the Web Store, the ID is fixed. You can rely on it.
For unpacked extensions in development, the ID is determined either by the "key" value in the manifest, if present, or the absolute path to the extension folder. So it may change if you move the extension about. But you can "pin" it by providing a valid "key".
Firefox
What you see in Mozilla is an installation-specific origin. No matter what the extension's ID is, the UUID you see here will differ on each extension install (but should persist through updates).
There's some discussion of the mechanism in this bug.
Essentially, this is an anti-extension-blocking technique.
This means you can't whitelist just one origin and be done with it, unfortunately.
Is it a good idea to rely on this?
Probably not. While browsers tend to report Origin faithfully, other tools capable of generating requests don't follow that. So it would be relatively easy to spoof.

chrome extension - will an extension update reset users settings/options page

I built a chrome extension, available in the Chrome Web Store, that has an options/settings page. In the settings, people can add additional webpages to a blacklist (the blacklist is already populated with some websites when the extension is initially installed).
I am now about to release a v2 to the chrome extension (mostly css improvements and an additional feature) and wanted to know, if people have added a bunch of new webpages to their blacklist via settings when using v1, will pushing an update to google cause their settings to be reset (e.g., back to the original blacklist)? The blacklist is held in localStorage.
Thanks
No, it will not reset your settings after an update, localStorage and chrome.storage will be kept.
Btw, you can test updating process by building a crx file. There are plenty of tools which can help you to make build; (oncletom/crx is the good one).

Get background page of a different extension

I have a personal chrome extension that always runs in development mode. I need it to communicate with a public extension (execute one of its function to be more specific).
Is there any way to get background page of the other extension so I can do this?
I also tried modifying source code of the other extension manually but then chrome show it as corrupted and ask me to reinstall it
Not really, no.
You cannot inject scripts into chrome-extension:// origin of a different extension, and attaching a debugger there (without whitelisted, private APIs) is going to be tricky (custom launch flags), if at all possible. Note that there's a feature request to allow that.
As suggested by wOxxOm, your best bet is to create a personal copy of the other extension (if at all possible); perhaps adding hooks for External Messaging or merging your code in.

How to upgrade extension to manifest v2 and remain backwards compatible?

I want to upgrade all my extensions to version 2 but still remain backward compatible for people that still have an older versions of chrome installed.
Since multiple manifest versions are currently unsupported, I would like to know which is the lowest version of Chrome that will support "manifest_version": 2 and its properties.
Manifest v2 was introduced in Chrome 18. Using Manifest version 2 adds several requirements to a extension, the most significant being:
The default Content Security Policy which disallows external JavaScript files to be loaded via <script> tags in extension's context, and which disallowes execution of JavaScript code which are created via a string: Inline event listeners, inline scripts, eval, etc.
A consequence of broken features are JSONP and eval-based templating engines. These can be solved by using ordinary cross-site AJAX respectively the sandbox Chrome 21+.
The web_accessible_resources field is initiated at an empty list and hence all resources are blacklisted by default.
The "background_page" manifest entry becomes unavailable (superseded by "background" + "scripts" or "page").
Manifest 2 also allows some APIs to be used, for example the chrome.storage API. When manifest v2 is left out, this message will appear below your extension.
Except for the last remark, all of these requirements result in a stricter coding guideline for Chrome extensions (compared to manifest v1).
Any code which complies with the CSP is also working in manifest v1.
All of the extension's sources are whitelisted, thus accessible to ordinary web pages.
"background": {"scripts": ["..."]} (and "page") is backwards-incompatible with Chrome 17 and lower, because it's introduced in Chrome 18. Use "background_page": "background.html" instead.
One extension for all Chrome versions can only be used if you're not using a background page. In other cases, such a hybrid (manifest v1+v2 compatible) extension cannot be achieved.
If you intend to distribute two different extensions, set "minimum_chrome_version": "18" in your manifest file. Don't forget to mention the location of the extension for older browsers.