2 * (C) Copyright 2009 John J. Foerch
4 * Use, modification, and distribution are subject to the terms specified in the
11 * Provides browser-object overrides for various commands at
12 * google-images, to follow directly to the page that contains an
13 * image, or directly save the full-size image. Never see that
14 * annoying frameset page from google again!
17 define_variable('google_images_imgrefurl_commands',
18 ["follow", "follow-new-buffer",
19 "follow-new-buffer-background",
20 "follow-new-window", "copy"],
21 "List of commands for which the google-images-imgrefurl browser object "+
22 "should be used in Google Images Mode");
24 define_variable('google_images_imgurl_commands',
25 ["save", "shell-command-on-file"],
26 "List of commands for which the google-images-imgurl browser object "+
27 "should be used in Google Images Mode");
29 function google_images_get_image_uri (I, prompt) {
30 var result = yield I.buffer.window.minibuffer.read_hinted_element(
33 $hint_xpath_expression = "//a[img]");
34 var u = Cc["@mozilla.org/network/standard-url;1"]
35 .createInstance(Ci.nsIURL);
40 define_browser_object_class("google-images-imgrefurl", null,
41 function (I, prompt) {
42 var u = yield google_images_get_image_uri(I, prompt);
43 var imgrefurl = unescape(/&imgrefurl=([^&]*)/(u.query)[1]);
44 yield (co_return(imgrefurl));
47 define_browser_object_class("google-images-imgurl", null,
48 function (I, prompt) {
49 var u = yield google_images_get_image_uri(I, prompt);
50 var imgurl = unescape(/imgurl=([^&]*)/(u.query)[1]);
51 yield (co_return(imgurl));
57 $enable = function (buffer) {
58 for each (var c in google_images_imgrefurl_commands) {
59 buffer.default_browser_object_classes[c] =
60 browser_object_google_images_imgrefurl;
62 for each (var c in google_images_imgurl_commands) {
63 buffer.default_browser_object_classes[c] =
64 browser_object_google_images_imgurl;
69 let (rx = build_url_regex($domain = "images.google",
71 auto_mode_list.push([rx, google_images_mode]);