Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to WebExtension (WIP) #176

Closed
wants to merge 33 commits into from
Closed

Port to WebExtension (WIP) #176

wants to merge 33 commits into from

Commits on May 1, 2018

  1. Un-obfuscate code

    Basically only whitespace and renaming variables and functions. Should
    be functionally completely equivalent to previous commit.
    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    c106258 View commit details
    Browse the repository at this point in the history
  2. Change XUL to WebExt: keep the magic, drop the logic

    - Add a manifest for webext version and remove install.rdf
    - Remove files & functions that do setup (bootstrap.js, ...)
    - Keep functions that do actual cleaning work (browser.js -> cleanlinks.js)
    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    4b17f6e View commit details
    Browse the repository at this point in the history
  3. Move l10n to webext setup

    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    1522a7f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bf15e40 View commit details
    Browse the repository at this point in the history
  5. Add content script to re-write URIs in pages/on click

    Remove recursive functions, as content scripts are injected in every frame.
    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    c421bca View commit details
    Browse the repository at this point in the history
  6. Update count of, and notify about cleaned links

    Add messaging between background and content script to send
    cleaned-click events and numbers of links cleaned.
    
    In background.js, update the count (on the badget text), notify the
    user, and (TODO) track the cleaned links for potential future
    whitelisting
    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    0ca773a View commit details
    Browse the repository at this point in the history
  7. Add options page, populate values & i18n strings

    Loading options and updating+storing options on change still to be done.
    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    da86103 View commit details
    Browse the repository at this point in the history
  8. Add options saving/loading/modifying

    Requires storage permission. Options are stored as they are displayed in
    the options page, and loaded based on the object types in the default
    values.
    
    All the main code is wrapped in the loadOptions.then() to be sure that
    we load options from storage before anything else.
    
    A message is sent to the background script to trigger a new loadOptions()
    whenever new values are saved, so that it stays up to date.
    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    23abe8c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    201c976 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    0551c96 View commit details
    Browse the repository at this point in the history
  11. Add names for icon variants

    Cimbali committed May 1, 2018
    Configuration menu
    Copy the full SHA
    840c5ba View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    74a6265 View commit details
    Browse the repository at this point in the history

Commits on May 2, 2018

  1. Configuration menu
    Copy the full SHA
    e2fd85f View commit details
    Browse the repository at this point in the history
  2. Respect event-mode option: do not always clean whole doc

    Also repeat the dirty hack to handle links added in a document with
    ajax, which consistss of running a clean again after repdelay seconds
    after a click.
    Cimbali committed May 2, 2018
    Configuration menu
    Copy the full SHA
    843767a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3b59089 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9f35b4e View commit details
    Browse the repository at this point in the history
  5. Add support for clean-link to clipboard copying

    A new contextMenu item is required for this, as we can't intercept the
    previous one anymore in web extensions.
    
    The setup for this feature is a little contrived:
    - copying to clipboard can not be done from a background script.
    - on links or selections, the target text (link to be cleaned) is
      available from the background script where the contextMenu event is
      handled.
    - otherwise, only the script in the page knows where the right click
      that triggered the contextMenu is, thus what the text is.
    
    Thus, organise the flow thusly:
    1. In injected content script, on right click, send text link around
       click position to background and wait for (optional) response.
    2. In background script, if our contextMenu item is clicked, get sent
       text link and clean it (or use a.href or selected text), and send
       cleaned link as message reply
    3. In injected content script, if there is a response to the message,
       copy it to the clipboard.
    
    NB.  Are we leaving hanging promises around? Or do they get GC'd?
    NB2. There might be a race condition when accessing lastRightClick, i.e.
         the saved text link message (content script (1.) -> background (2.)).
         If clicked too fast, maybe the message didn't arrive yet. To fix
         that, we probably would need to wrap lastRightClick in another
         promise.
    Cimbali committed May 2, 2018
    Configuration menu
    Copy the full SHA
    b3a5868 View commit details
    Browse the repository at this point in the history

Commits on May 6, 2018

  1. Make sure handleMessage returns a Promise

    Also fix gotarget comment
    Cimbali committed May 6, 2018
    Configuration menu
    Copy the full SHA
    e89cd51 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d64d1d4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    da48a19 View commit details
    Browse the repository at this point in the history
  4. Add a preference to know whether we switch to new tabs

    There is a browser preference that controls this:
    "When you open a link in a new tab, switch to it immediately"
    
    However this preference is not available through the browserSettings API:
    https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/browserSettings
    Cimbali committed May 6, 2018
    Configuration menu
    Copy the full SHA
    bfacefb View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8159600 View commit details
    Browse the repository at this point in the history

Commits on May 13, 2018

  1. Configuration menu
    Copy the full SHA
    d36e3d5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    689adcd View commit details
    Browse the repository at this point in the history
  3. Only enable modifying requests when OMR is enabled

    Also move the cleaning function to cleanlinks.js.
    
    Perform the cleaning in the onRequest function by returning the
    {redirectUrl: ...} object if we have a cleaned link.
    
    Integrate as comments all fixes from the original XUL code in case those
    bugs show up again.
    Cimbali committed May 13, 2018
    Configuration menu
    Copy the full SHA
    0c16959 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    dc8f353 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9e38a74 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d5379f9 View commit details
    Browse the repository at this point in the history
  7. Adjust default options

    Cimbali committed May 13, 2018
    Configuration menu
    Copy the full SHA
    282fb2f View commit details
    Browse the repository at this point in the history
  8. Update some messages

    Cimbali committed May 13, 2018
    Configuration menu
    Copy the full SHA
    098c08e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ba0965c View commit details
    Browse the repository at this point in the history
  10. Correct icon size in manifest

    Cimbali committed May 13, 2018
    Configuration menu
    Copy the full SHA
    61ee3b5 View commit details
    Browse the repository at this point in the history
  11. Update regex-stripping of javacript: in links

    The AMO parser was throwing a syntax error on parsing the previous
    version for some reason. Logic remains the same: identify a link in a
    jacascript:... text and keep just that.
    Cimbali committed May 13, 2018
    Configuration menu
    Copy the full SHA
    294fa3e View commit details
    Browse the repository at this point in the history