Another unnecessary extension for Google Chrome?

Good day, dear harazhitel. From the title of the publication, it becomes clear that under the cut you are waiting for the story of the birth of the next unnecessary extension for the browser from the search giant Google. As you know, the title is provocative, and the need for an extension for the browser is a rather subjective question. Therefore, I suggest that you independently render a verdict and evaluate the level of "unnecessaryness" of this product. Or be satisfied with a small amount of time wasted in vain and pass by.

fast search screenshot

It all started on a regular working day: when I was searching for text on a page that was open, as it most often happens, in my favorite browser, Chrome, I wondered: why is my dear Chrome not looking for the text selected with the mouse right away? Every time I have to spend annoying galaxy Ctrl + C Ctrl + F Ctrl + V. Maybe there is some other combination: Shift + F or Alt + F? Alas, the lame one does not know how - and that’s the point.

Interviewed colleagues: did they ask a similar question and how they relate to such a not-so-productive bunch of keyboard shortcuts for a simple search for selected text. It turned out that no one was parsing about this. And the adherents of the fox generally smiled so slyly, because the redhead knows how. Checked: yes, yes - he can. No, well, seriously: is it really bothering anyone? After all, any IDE and even any self-respecting text editor immediately searches for the selected text. Why can't the search giant organize a comfortable page search in its browser?

Checked in Opera 12.15 - can not. Of the chrome-like ones, OperaNext checked and YaBrowser - they do not know how. The donkey, as it does not progress, in it and after a long Ctrl + C Ctrl + F Ctrl + F Ctrl + V is not searched for anything without a mouse. Since changing the browser is not an option, I have finished researching in this regard.

Here, once again, I realized that the world was not perfect, and decided: I’ll find an extension for this business and everything will fall apart at the moment. Naturally, I also considered and rejected the option with software for remapping keys. As one member of the class said to the other, “This is not our method, buddy.”

You know, extensions for chrome look for everything and everywhere, except for the selected text on the current page. Well, honestly: you can choose any search engine and search the entire site, both on Wikipedia and in highly specialized areas, and even, probably, among non-open stars, but just not what I need. So, after the fifth installed and immediately removed extension, the thought came up: why don't I learn how to write extensions for my favorite browser, just by the example of what I need, and not some customer there?

No sooner said than done. It would be in a fairy tale about Ivanushka the developer, but for me, or rather, for us, it took 3 weeks. Well, clean, of course, 30 hours of strength will be typed, because only free time was devoted to this, and even that was not all. I wanted over the weekend, on my knee, so to speak, to scratch and publish on Sunday evening. Well, why is there something business? I planned, without any interfaces for you, to copy the selected text to the clipboard, also Ctrl + F, then open the chrome search form and paste the text from the clipboard there. Super solution: save Ctrl + C and Ctrl + V for posterity (don't wear out the keyboard). Extremely quiet tube background extension for Chrome.

As you know, by this moment I was firmly convinced of the imperfection of the mortal world, so the dark side prevailed. I was going to intercept the event of pressing Ctrl + F, if there is selected text, take it to the buffer, emulate pressing Ctrl + F already for the browser [such a non-existent .resumePropagation ()] and in the search form that opens, again, emulating pressing Ctrl + V, Paste the copied text.

For those who started to read the post not from the very beginning, let me remind you: this is my first experience writing extensions for browsers in general, and for Google Chrome in particular. Yes, this insidious feint has not pierced the ears, security, sandbox and all that ... All because someone eats a lot! Or rather, because event.initKeyboardEvent, as you do not initialize it, flies with zeros. Who does not believe - opens the browser console and inserts the code:

var event = document.createEvent('KeyboardEvent');
event.initKeyboardEvent('keydown', true, true, window, false, false, false, false, 65, 65);
event.keyCode = 65;
event.which = 65;
event.charCode = 65;

And who knows how to treat, he knows what to do in the comments.

On stackoverflow, they say that this is a webkit bug that has been hanging in the bugtracker since 2012. But a born coding should not teach the corporation of good how to fix bugs. We go further ...

Well, I thought nicely, I. All these dirty methods are not for us, for sure, the API for extensions for the browser of the search giant gives access to the search form. I will be immensely glad this time to make a mistake, and let it turn out that it is possible to open this field to enter the desired text programmatically from the extension and insert at least a line into it ... Honestly, who will tell you how, I will finish this functionality and add it to the co-authors, if you wish.

Since I did not find such an opportunity, I decided to go to the victorious .crx -> embed my search form on the page and use my search engine. The engine, of course, is said very loudly. Since the Salute bike was looming, I at least hoped to honestly copy this part from someone on the expanses of your Internet. And the first options claimed by their authors as a page search did terrible things: they broke page layout, searched in all elements, including script, style, img and others, did not work with UTF-8 and much more that could frighten programmers' children.

At this stage, the team has grown, or rather: doubled. I asked for help in drawing a search form from a friend David, who is also a designer. We must pay tribute: the design department worked wonderfully and by the time we left the beta we had a unique custom main extension menu and 6 themes.

What we have in the end: extensions for chrome with its own search form, with the ability to customize the highlight color of the found text and the current found fragment, text. It is possible to intercept pressing Ctrl + F and F3, this is in case you really like our solution and you get tired of comparing it with the native search for Chrome. Especially for comparison with the built-in search, the search form is initially displayed in the upper left corner, you can place it in the upper right corner from the settings in the main menu. On the main settings page, the highlight colors are customized and the UI themes change. Also for each topic there is a minimalistic version of the search form: in one line.

The parsimony of the graphics in the post is explained by the fact that all the funny pictures are in the source codes on the github . Yes, and you can touchhack by installing from the extensions store. At the time of writing, draft version 1.0.4 has fixed a search bug in hidden elements, i.e. they, of course, were not displayed, but were taken into account in the output of the results of the number of options found. Hidden means display: none. So if you are lucky and will publish 1.0.4 in the morning, then you will be happy. And on the github , of course, lies freshly.

And of course: I'm not PR, but the moral of this fable is this: let it happen and this extension will kick Google in improving the usability of its own browser. Thank you all for your attention and, possibly, for getting out of read-only. Who was completely bored - I give my Scottish straight:
scottish straight

Also popular now: