
How many of you remember some time ago, Google for the second time hid the link to Reader, replacing it with a link to Photos. For the first time, this caused a wave of user dissatisfaction and Google returned everything, citing an error. Then, immediately, an extension for Chrome appeared, returning the link to Reader. I have ported this extension for Opera.
The second time Google moved the link, the wave of indignation was no longer so strong. At first it seemed to me that no one paid any attention. The community was busy with more important news. But there was a discussion on Google’s support forum and even an
official response that Google always seeks to improve its products and such an improvement can lead to actions similar to what happened with a link to Reader. I remembered my extension, uncovered a dusty code, and decided to make the extension more pleasant and more meaningful. Namely - to give the user the opportunity to set the link structure himself. The extension should dynamically pull out all links from the page, show them to the user in the form of two columns and allow them to be dragged with the mouse. It turned out that for Chrome there was no such extension either, and additionally I wondered to write two extensions with common code.
Extensions Architecture
The architecture of extensions is similar in both browsers. It is conditionally possible to divide the internal part of the extension into what works in the context of the page being viewed and what works in the context of the browser. Why is it important to separate these concepts? Because for the scripts implemented on the page, there is a more stringent security policy. For example, I could not connect a third-party script. I have jQuery library as such a third-party script. At the same time, the script that works in the context of the browser, without any problems, connects anything. For more specificity, let's call scripts by their names: the background process works in the context of the browser, the built-in - in the context of the page.
The interaction between the background and the built-in scripts takes place through messages. You need to hang up message handlers there and there and go. Implementation details have already been
covered on Habré.
')
Code
If we talk about the code, we can highlight several interesting points:
- Trouble debugging. Sometimes the extension just stopped working, there was nothing in the log. Then it turned out that there was a syntax error somewhere and everything was quietly dying. It happened to me 1 or 2 times. I could not reproduce such an error artificially, and in the logs I always received an indication of the place of the syntax error.
- You can do everything according to the documentation, and then it turns out that messages are not sent. If the main functionality of the extension is tied to messages, then it stops working. In the log, of course, no information is displayed. This led to the fact that at some point I began to generously cover my code with debugging messages, so that I could trace where the control of the script still falls, and where it does not.
- In my opinion internationalization is made in Chrome better than in Opera. Opera follows the recommendations of the W3C about the widgets and suggests for each supported language to create a separate folder with a full copy of the extension translated into the desired language. I see a problem here that when you need a little bit to correct the layout in one of the files, you will have to do this in all copies of this file. Chrome stores only text messages in different folders and allows you to access them by ID.
- In the file with extension metadata (
config.xml
for Opera and manifest.json
for Chrome), you can allow access to other sites. In Opera, you need to be attentive with slashes. Instead, for example, <access origin="https://mc.yandex.ru/" subdomains="true" />
write <access origin="https://mc.yandex.ru" subdomains="true" />
In the first embodiment, the extension does not gain access to the specified page. - In Chrome, for an embedded script, you can specify the pages on which it should run directly from the manifest. Generalization characters are supported. For example, to make the script work on all pages of the
google.com
domain, you can write *://*.google.com/*
. But you cannot write *://*.google.*/*
so that the script works on any domain with the word google
. My extension should work on any Google domain, so it contains 182 domain records.
Technical documentation and related materials
The level of assistance to the developer Opera and Google differ slightly. Both companies provide detailed documentation, videos, examples. Subjectively, it's harder for me to read Google's documentation. They are very fond of hyper-links and reading turns into a leapfrog: read a paragraph, click on a link, read a paragraph, switch either on a new link, or back. A separate quest from Google: try to go to
the documentation page and find recommendations for publishing an extension. Google is increasingly focused on applications, rather than extensions. Background information about the process for publication is on the
application development pages .
The Opera did a great thing - templates for creating icons. Templates can be used in Photoshop or Inkscape. I am far from design and it took me some time to master this pattern, but then I appreciated it in its true worth. With it, it's really easier to create icons of the right size.
Chrome Web Store and Opera Extensions
| Opera | Google |
---|
Localization and description of the extension | Invites the developer to fill in the description in all localization languages, showing the input fields one by one | Shows only one input field. Switching to another language is done using a combo box. I did not immediately find this combo box and thought that for some reason I can enter a description only in the language selected by default |
Screenshots | There is only one size requirement - screenshots must be less than 800x600 pixels | They offer to make screenshots of a fixed size of 1280x800 pixels. Additionally, they offer to make several advertising images. Expansions without advertising images receive less attention in search results. |
Visibility extensions | There is a section - new arrivals. Through it, people can at least somehow learn about updates or updates. I think that my expansion was noticed because of this section. | There is no information about new extensions. The published extension immediately goes into the common boiler and is very difficult to find through the official catalog. |
Google gradually teaches us to useless URL. Surely there are people who go on Facebook, stuffing facebook in the search and following the link. Why do we need an address to remember, if there is a Google that remembers everything for us? As a result, extensions in the Chrome catalog have excellent identifiers of the form
jlmhhcdodlafcgaopokedcaejpbiagkk
. Try reading the text and encountering two links.
chrome.google.com/webstore/detail/jlmhhcdodlafcgaopokedcaejpbiagkk
chrome.google.com/webstore/detail/jlmhhcdodlafcgaopokedcaejpbiagkk
and
chrome.google.com/webstore/detail/iiamfmleocemmjdnbfifnmdgekeokakh
chrome.google.com/webstore/detail/iiamfmleocemmjdnbfifnmdgekeokakh
, understand which link refers to which extension. Opera creates a link based on the name of the extension.
About people
People do not read already written comments before sending theirs. Actually, this is not news for any blogger, but nonetheless. Take the same thread on the Google forum. It is 99% percent of the messages "return back the link to the Reader." In this thread, I left a link to my extension. It seems no one noticed. Everyone continued to write angrily about the return of the link. Someone even released another such extension (just changing the links in some places) and also wrote about it in the thread. A small discovery was how one person really liked my extension, and he went and wrote about it all on the same Google forum and gave a link. His message, unlike mine, did not go unheeded.
In the Opera, several times people wrote that they rated 3 or 4 because of that and because of that, but they missed it with a mouse and actually put it 2. This is, firstly, the issue of usability. Perhaps such a rating on Habré (plus and minus) would be clearer. Secondly, you do not get a rating that would make your extension more visible to users. Thirdly, if you are prone to worry much about the rating, then your experience will increase.
Statistics
I was very surprised by the approach to statistics from the search giant. The developer is available a figure called "number of users per week." This figure tells me little. The fastened statistics of Google analytics helped to understand that they still use my extension in Chrome. Opera also shows an easily understandable figure - the number of downloads. With this figure I will not need additional statistics to understand the relevance of the expansion. But in both browsers I do not know anything about those who may have installed the extension for themselves, and then deleted it. So, in general, I would like more informative staff statistics from both browsers.
I screwed two buttons for donations: from the paper and Yandex.deg. By the time the second version was published, I received exactly zero donations. I can not say that I was very surprised. As it is known, very few projects can collect donations. I wanted to make the second version of the extension conditionally paid: the full functionality would appear 10 days after installation. If someone wanted before, then you would have to pay some symbolic amount. A few things stopped me (I have no legal entity). The first is the lack of adequate payment systems for non-residents of the United States. Found only Paypal, in which I have an account in euros. According to statistics, I saw that the majority of users of the Chrome-version of the extension from the States. I was not sure that they would be willing to pay 1 euro for the extension and another 1.5 for related costs. In addition, it was necessary to organize payment acceptance and reliable (affordable) storage / receipt of information about them, which means that the server part of the extension is needed.
The second is ethical considerations. I have nothing to do with Google, so why should I parasitize on it, even spending my own time ?! I got experience, and money is better to make money on something that will be completely mine.
Version update
Chrome supports auto-update versions, but if you change the list of necessary permissions in the new version, auto-update is disabled. The user will have to find out for himself that a new version has been released and to click the “Update all installed extensions” button himself. In the Opera, the situation is similar. After changing the access rights in the manifest, messages about the new version did not come.
Results
- Writing cross-browser extensions is very possible and in fact not so difficult.
- Extensions are supposed to be free. If you suddenly want to make a profit, browser developers will not help you with this. For profit it is worth looking towards applications in the Chrome Web Store.
- For Chrome, you need to think about advertising somewhere on the side. Otherwise, no one will know about your wonderful extension.
UPD: Wimsey clarifies that there are auto-
updates in Opera. Text corrected.