Extensions designed to enrich your browsing experience

Download Control

Download ControlSomething new – AGAIN!

My last post over at my old blog hinted to a new extension. Some of you may have thought that “I already got an idea for a new extension, which Opera’s still lacking an API for atm” addressed Sexy Dialog, but it didn’t (I actually didn’t even plan to develop Sexy Dialog back when I wrote this post).

As the title says, this mysterious extension is called “Download Control”.

What is it about?

Download Control is meant to enhance download handling (Who would have guessed?).

So far, it “only” has two features:

  1. You can add rules where your downloads are supposed to be saved on a per site or per file type basis.
    Therefore, open Download Control’s options page. You’ll then find three sections of rules as well as a field for the default path.
    Priority of rules is from top to bottom (first rule that matches determines download location).

    What’s the default path for? It’s set in Chrome’s settings, right?

    True, but it’s not as easy. Let me explain that to you:
    Chrome has limitations to what an extension is allowed to do. One of those is that Download Control can only save files in the default download directory specified in Chrome’s settings and its subdirectories (including the ones it possibly creates for you). To overcome this limitation, you need to set Chrome’s default download folder to include all folders you want to save files in.


    I want to save documents in my “Documents”-folder (C:\Users\me\Documents) and the rest in “Downloads” (C:\Users\me\Downloads).
    Chrome’s default default  download folder (Oh boy! That’s where I lost the last of you guys ^^) is “C:\Users\me\Downloads”. That doesn’t include the “Documents”-folder.
    Hence, go to Chrome’s settings and change “C:\Users\me\Downloads” into “C:\Users\me” to include all folders.
    To avoid all files that don’t match any rules ending up in “C:\Users\me”, enter “Downloads\” as Download Control’s default path so it gets added if no rule matches.

    OK, I got that. Now how do I add rules?

    At the bottom you’ll find three input fields:

    1. Website:
      for casual users: just enter a part of the URL, e.g. “my.opera.com” or “google.com/docs”
      for advanced users: it supports regex! So you can also write something like “\d-(zip|miles).(com|org|net)$” (don’t expect this example to make a whole lot of sense :D)
    2. File type:
      just enter one or more file endings (comma separated), e.g. “pdf, doc, docx”
    3. Folder:
      The sub-folder (relative to Chrome’s default download folder as mentioned above) you want to save files matched by this rule, e.g. “Documents\”
      Additionally, you can also add variables to the path. At the point of writing, there are two of them “%DOMAIN%” and “%FILETYPE%”. Whenever you use those, they’ll get substituted with the corresponding domain / file type. A possible path could e.g. look like “Documents\%FILETYPE%s\”

    Now you’re all set. Add some rules and test it 🙂

  2. You can specify what to do in case a file with the same name already exists.
    This is a lot easier to explain: Click “Settings” on the left menu and choose whatever you want it to do 😉

Sounds cool? Test it!

If you are using Chrome or Opera 20 Dev, you can get Download Control 1.0 alpha here 🙂

As it’s an alpha version, it’s not feature complete yet, so let me know what you’d like to see, what needs to be improved etc. (Some cheering is appreciated, too) 😉


Comments on: "Download Control" (17)

  1. Humm, this answers a lot of questions.

  2. Very nice! 🙂

    • Glad you like it 🙂
      Let me know if you got feature requests or bugs 😉

      btw: editing of rules is implemented already and coming in next build. No need to report that 😉

  3. myoperaexile said:

    Thanks for this! A bug report for you:

    The global variable “path” only gets reset once (upon first loading the extension) in DownloadControlBG.js; this means if path is non-empty on entry to the handler _and_ the path is not set during the first for loop, it won’t get a chance to be set in the 2nd or 3rd. I modified the listener to set path = “” before the first for loop, inside the main listener handler, and it works better now. (I have only extension rule set so far, which is how I found this issue).

    • Wooops. Yeah, that’s a remainder of internal testing. This variable isn’t supposed to be global in the end at all 😉
      Gonna be fixed in next build. Thanks for your report! 🙂

    • I was just about to report the same “path” init issue that myoperaexile mentioned. 😉

      You could think about transforming the ”background page“ into an ”event page“ (declaring ”persistent: “false”“ in the manifest).

      You also probably already plan to do some sanitation on the path names (or rather fragments thereof) – forward slash vs backslash and (enforcing/removing) trailing slashes come to my mind.

      One more thing: You could also allow rules based on mime types (though this would perhaps require a different strategy storing the rules)…

      Nice work! 🙂

      • No, I actually don’t plan to implement correction of slashes etc. – cause it’s working already (for rules; gonna be ported to default-path of course) 😛

        I’m gonna give mime-types a thought 🙂

        P.S: I fixed niche for you 😛

      • Thanks for fixing the commenting mess I left. 😉

        You are right, I forgot to look at the options script, where you certainly handle user input alright, sorry.

        Initializing the global settings object ”w“ you have a theoretical race condition there (unless you can argue against it using some ECMA threading / execution sequence guru knowledge ;)), when querying storage hasn’t completed yet, but the ”downloads.onDeterminingFilename“ event handler already gets invoked by an event (not very probable scenario, I agree – don’t know if you should bother, though, since this is Download Control, not Rocket Control ;))..

      • I guarantee, that you’ll never ever run into trouble there ^^
        It’s save to ignore this theoretical race condition

  4. Opera 20 is available and with the chrome.download API!!!
    Now we can really use this extension.

  5. Wow, thanks for that. I always wanted this feature in Opera.

  6. […] Download Control 1.0 alpha 5 here You can have a look at my initial post about Download Control to learn about some advanced possibilities like using regexps and variables in […]

  7. […] during alpha-stage, you can find an elaboration of Download Control’s basic concept in its initial post. You can also find some more in-depth knowledge there. So go ahead and read about using regexps and […]

  8. […] during alpha-stage, you can find an elaboration of Download Control’s basic concept in its initial post. You can also find some more in-depth knowledge there. So go ahead and read about using regexps and […]

  9. […] during earlier stages, you can find an elaboration of Download Control’s basic concept in its initial post. You can also find some more in-depth knowledge there. So go ahead and read about using regexps and […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: