This script searches the selected text in the page for links, and follows the first one found. Very handy when combined with searching.

(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;
            }
        }
})();

I find it useful to bind it to ctrl+return like so:

@cbind  <Ctrl><Return> = script @scripts_dir/followSelected.js

Then I can search for the text of the link and hit ctrl+return when I get to it. Just like text-based browsers and vimperator.

Got the idea from this post.

 
followselected.js.txt · Last modified: 2010/02/08 23:00 by israellevin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki