FollowSelected

Script

Note, this script is stolen from the Uzbl wiki

Save the following file as $XDG_DATA_DIR/luakit/scripts/followselected.js

(function() {
        var selection = window.getSelection().getRangeAt(0);
        var container = document.createElement('div');
        var elements;
        var idx;
        if('' + selection){
            // Check for links contained within the selection
            container.appendChild(selection.cloneContents());
            elements = container.getElementsByTagName('a');
            for(idx in elements){
                if(elements[idx].href){
                    document.location.href = elements[idx].href;
                    return;
                }
            }
            // Check for links which contain the selection
            container = selection.startContainer;
            while(container != document){
                if(container.href){
                    document.location.href = container.href;
                    return;
                }
                container = container.parentNode;
            }
        }
})();

and bind it to some key, for example:

table.insert( binds.mode_binds['normal'], lousy.bind.key({},            "Return",   function (w, c)
    w:eval_js_from_file(lousy.util.find_data("scripts/followselected.js"))
end))

Use

I find it quite useful in connection with luakit bookmarks. For example when I open bookmarks, I can search for given string, and than just press enter twice to follow that link.

Also available in: HTML TXT