What they called me paranoid and what came of it

    When the leak of password / hash databases began from different forums and social networks. networks, I began to think about how and where to store my passwords, so that they can be changed quickly and not be forgotten. So I came across the KeePass Password Safe program , I won’t write about its capabilities, because there are plenty of articles on the Habré and the topic of this article is not about its capabilities. During operation, KeePass was overgrown with plugins, especially for bundling with browsers, LastPass was discarded because it did not want to store passwords somewhere (especially for working systems), and it wasn’t a fact that they won’t merge them from there either.

    At first for Firefox there was a KeeFox extension , but since through KeePassRPC(KeePass plugin) only it works - now this extension has been disabled for a long time and is not used. Then the PassIFox extension was found (it works through the KeePass plugin - KeePassHttp ) with ChromeIPass right away - but for Opera 11, Opera 12 (hereinafter, it will be assumed on the Presto engine and this is my main browser) there was no good integration, there was only A UserJS script that adds a page address to the window title, an extension was created that does the same thing - in order for KeePass to determine the address for which you need to search for a username and password for substitution by Ctrl + Alt + A (standard KeePass auto-fill hotkey) . Since I don’t have modern JavaScript skills , I tried my luck onOperaFan asking to write / redo an extension for Opera - where they called me paranoid. Continuation of the story about porting ChromeIPass to Opera 12 (without much technical details) under the cut.

    Important

    I’ll make a reservation right away that I didn’t manage to port everything, but it turned out to be quite efficient for me, given the lack of an alternative. I ask you not to kick for mistakes and implementation errors. If someone tells me something, I will correct it. I will be grateful.
    I understand that Opera on the Presto engine is already a corpse, but as I wrote above it is my main browser and so far I do not see a replacement for it in terms of memory consumption, speed and the ability to finish the functionality. I use the latest assembly of Opera AC with dopplennymi buns for myself.

    The first approach to the shell


    For porting to Opera, the ChromeIPass extension was chosen because by looking inside it and LastPass extensions, RoboForm Lite and seeing approximately similar calls for Opera and Chrome - I made the assumption that they are closest (in time I realized that I was very mistaken).
    The first patient at that time was version ChromeIPass 1.0.7. There was no functionality for remembering passwords, scanty little knowledge about writing extensions and their interaction with the browser, little free time, the LastPass extension, just like RoboForm, were written universal immediately under Opera, Chrome and Safari and were huge. There was a simple replacement for chrome.extension.sendMessage with opera.extension.postMessage with the natural "epic fail". In general, after making several attempts, I abandoned porting, although there were few scripts and I was ready to put up with adding passwords through KeePass itself.

    The second approach to the projectile


    Two months ago, I discovered that the version of ChromeIPass is already 2.6.6 and it has the functionality of remembering passwords and a number of other goodies. And it even works without any changes in Opera (on the blink engine), slipping it in developer mode, and then you can convert it to NEX.
    This time it was decided to unequivocally achieve a working result. Having thoroughly read about the interaction of the Injected script, Background script and Popup script in Opera, google, looking at other extensions, clambering around the already closed forum and blogs on My Opera (I even had to dig into the Web Archive and google cache) - I got to work. Config.xml

    was created, the files were transferred to the necessary directories, chrome.extension.sendMessage was replaced by opera.extension.postMessage (in some places one.source.postMessage where it was necessary to respond to the event - and not just send, e is the event , because ChromeIPass has an event object defined in event.js).

    All calls using the callback mechanism in Chrome have been redone to simply send events and added reactions to these events in event handlers, where these callback functions are defined.

    Redone chrome.tabs. *. AddListener on opera.extension.tabs. * (For Opera, events in lower case must not work otherwise) in init.js.
    opera.extension.tabs.onupdate in Opera (chrome.tabs.onUpdated.addListener in Chrome) does not work .

    Enabled debugging (displaying messages in the console) where it was, adding your debugging messages to understand what and how and with what it interacts.

    A new extension was added in developer mode to a separately installed opera and Dragonfly was launched.

    A lot of useful information was taken from the posts and blog of the user Joel Spadin aka spadija on my.opera.com and its extensions tab vault , autostack .

    First I checked how the extension works with KeePass, in this part I did not redo anything. works with a bang.

    Implementation of CSS was done ( it was here ), as I later discovered the same method used in the documentation

    Then there was a struggle for the loading sequence of Injected scripts (in ChromeIPass there are three of them: the main one and two redone jQuery and jQuery UI). In Chrome, this is easier than in the Opera.
    The solution was found on the my.opera forum (no longer available) and for jQuery (in ChromeIPass jQuery was renamed to cIPJQ so that there were no conflicts with the loaded jQuery from sites) its initialization code was added in init.js so that it wouldn’t throw out errors and worked
    var cIPJQ;
    if (typeof cIPJQ === 'undefined') {
      if (typeof window.cIPJQ !== 'undefined') {
        cIPJQ = window.cIPJQ.noConflict(true);
      } else {
        opera.postError(['Error: could not load jQuery']);
      }
    }

    I stepped on a rake that opera.extension.bgProcess is a window object - and not the background script itself.

    The work with replacing addresses for popup has been redone, the solution was taken from here , while there is still a Google cache.

    But the ports had to tinker the longest. So, if you transfer the port from the popup script to the injected script and vice versa ( as indicated in the documentation ), e.source.postMessage for events from the popup script in the background script completely stops working . I had to create another MessageChannel to work popup script c background script. And "poke" the closure of all these MessageChannel, tk. there are problems that when creating tabs the opera.extension.tabs.getSelected () functionreturns a tab with port = null.

    To embed images, I first tried opera.extension.getFile () , but it turned out to be asynchronous, so I implemented image loading just like CSS loading (via XMLHttpRequest) and replaced the base64 encoded images when introducing styles.

    The extension itself:
    rghost , sendspace
    with uncommented
    postError rghost , sendspace

    Limitations


    • If you change the port for connecting to KeePassHttp, you need to edit it />in config.xml due to limitations in the specification for which the network access control of extensions in Opera is implemented.
    • Interception of HTTP authorization does not work, because Opera simply does not have such an interception mechanism.
    • There are many “Unknown pseudo class” errors in the console indicating the CSS attribute “: first”. At least in Dragonfly there were just a ton of them.
    • Sometimes I have to refresh the page due to problems with the ports, I still could not find out why when creating new tabs, the value port = null.
    • It does not work out alert () in the background script, while there are no errors.
    • Copying the password to the clipboard from the password generator does not work, I haven’t really dug it yet. need to smoke specification


    Thanks for attention!

    Also popular now: