Hi all,

There is a technique that can be employed to have Conkeror do an automatic
redirect when you visit a given url pattern.  I use this with Google
Images to skip their intermediary page and jump straight to the image, as
described here:

  http://conkeror.org/Tips#ClientRedirect

I had been meaning to abstract this technique into a general-purpose
module, and finally got around around to it.  Attached is the first
implementation.  By this implementation, configuring a client redirect is
now much more concise:

  require("client-redirect");

  define_client_redirect("google-images",
      function (uri) {
          return /(images|www)\.google\.com$/.test(uri.host)
              && uri.filePath == "/imgres"
              && regexp_exec(/imgurl=([^&]+)/, uri.query, 1);
      });

The general syntax is: define_client_redirect(name, from, to);

The argument 'from' may be either a regexp or a function.  If it is a
regexp, a 'to' procedure must be given to transform the result of the
match into a new url.  If it is a function, the function should return the
new url itself.

What do people think of this design?  Seem good, or is there anything I
missed?

-- 
John Foerch
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to