diff options
| author | R.T. Lechow | 2011-01-04 19:02:53 -0500 |
|---|---|---|
| committer | R.T. Lechow | 2011-01-04 19:57:29 -0500 |
| commit | 5f944bc99c7cb25412d4f7a51b946b27a14ca77d (patch) | |
| tree | fff356a668877a2b2fe6b0473af2711a0f26a590 /vimiumFrontend.js | |
| parent | fdc320339e8cbdf978fe2259f247eec2e182a65f (diff) | |
| download | vimium-5f944bc99c7cb25412d4f7a51b946b27a14ca77d.tar.bz2 | |
Commands for following 'previous' and 'next' links.
Diffstat (limited to 'vimiumFrontend.js')
| -rw-r--r-- | vimiumFrontend.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index eb3de996..0ee3f762 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -550,6 +550,32 @@ function performBackwardsFind() { findModeQueryHasResults = window.find(findModeQuery, false, true, true, false, true, false); } +function findAndFollowLink(linkStrings) { + linkStrings.forEach(function(findModeQuery) { + findModeQueryHasResults = window.find(findModeQuery, false, true, true, false, true, false); + if (findModeQueryHasResults) { + var node = window.getSelection().anchorNode; + while (node.nodeName != 'BODY') { + if (node.nodeName == 'A') { + window.location = node.href; + return; + } + node = node.parentNode; + } + } + }); +} + +function goPrevious() { + previousStrings = ["\bprev\b","\bprevious\b","\u00AB","<<","<"]; + findAndFollowLink(previousStrings); +} + +function goNext() { + nextStrings = ["\bnext\b","\u00BB",">>","\bmore\b",">"]; + findAndFollowLink(nextStrings); +} + function showFindModeHUDForQuery() { if (findModeQueryHasResults || findModeQuery.length == 0) HUD.show("/" + insertSpaces(findModeQuery)); |
