[Request] Mouse gesture for navigating between pages



  • I like the idea of having custom mouse gestures and maybe Vivaldi will have such feature in the future. But what I really want is a mouse gesture to navigate on websites that are paged like this forum for example. I know that there are Chrome extensions that can be used, but this feature is so common it should be built-in. e.g. Next Page with RULDR (a ribbon from left to right) Previous Page width LURDL (a ribbon from right to left) The problem for such a feature is that the HTML standard to define links as "next page" or "previous page" is not widely used. The website has to be searched for several keywords (in different languages) within several tags/attributes and the best match has to be used. I wrote a piece of JavaScript which covers the most tags and keywords in English and German. [code]// const Keywords = ["prev", "newer", "later", "vorher", "zurück", "rückwärts", "‹"]; // previous page const Keywords = ["next", "older", "earlier", "nächst", "weiter", "vorwärts", "›"]; // next page var regexp = new RegExp("(?:" + Keywords.join("|") + ")", "i"); var links = document.getElementsByTagName("a"); for (var i = links.length - 1; i > -1; i--) { if (links[i].hasAttribute("rel") && links[i].getAttribute("rel").match(regexp)) { links[i].click(); return; } } for (var i = links.length - 1; i > -1; i--) { if (links[i].hasAttribute("data-link-type") && links[i].getAttribute("data-link-type").match(regexp)) { links[i].click(); return; } } for (var i = links.length - 1; i > -1; i--) { if (links[i].hasAttribute("alt") && links[i].getAttribute("alt").match(regexp)) { links[i].click(); return; } } for (var i = links.length - 1; i > -1; i--) { if (links[i].hasAttribute("id") && links[i].getAttribute("id").match(regexp)) { links[i].click(); return; } } for (var i = links.length - 1; i > -1; i--) { if (links[i].hasAttribute("class") && links[i].getAttribute("class").match(regexp)) { links[i].click(); return; } } for (var i = links.length - 1; i > -1; i--) { if (links[i].hasAttribute("value") && links[i].getAttribute("value").match(regexp)) { links[i].click(); return; } } for (var i = links.length - 1; i > -1; i--) { var images = links[i].getElementsByTagName("img"); for (var j = images.length - 1; j > -1; j--) { if (images[j].hasAttribute("alt") && images[j].getAttribute("alt").match(regexp)) { if (links[j].hasAttribute("href") && links[j].getAttribute("href") == "#") continue; links[i].click(); return; } } } for (var i = links.length - 1; i > -1; i--) { var images = links[i].getElementsByTagName("img"); for (var j = images.length - 1; j > -1; j--) { if (images[j].hasAttribute("title") && images[j].getAttribute("title").match(regexp)) { if (links[j].hasAttribute("href") && links[j].getAttribute("href") == "#") continue; links[i].click(); return; } } } for (var i = links.length - 1; i > -1; i--) { var images = links[i].getElementsByTagName("div"); for (var j = images.length - 1; j > -1; j--) { if (images[j].hasAttribute("class") && images[j].getAttribute("class").match(regexp)) { if (links[j].hasAttribute("href") && links[j].getAttribute("href") == "#") continue; links[i].click(); return; } } } for (var i = links.length - 1; i > -1; i--) { var images = links[i].getElementsByTagName("span"); for (var j = images.length - 1; j > -1; j--) { if (images[j].hasAttribute("class") && images[j].getAttribute("class").match(regexp)) { if (debug) alert("<a> <span class="">found: " + images[j].getAttribute("class")); if (links[j].hasAttribute("href") && links[j].getAttribute("href") == "#") continue; links[i].click(); return; } } } var forms = document.forms; for (var i = forms.length - 1; i > -1; i--) { var inputs = forms[i].getElementsByTagName("input"); for (var j = 0; j < inputs.length; j++) { if (inputs[j].hasAttribute("type") && inputs[j].hasAttribute("value") && inputs[j].getAttribute("type") == "submit" && inputs[j].getAttribute("value").match(regexp)) { inputs[j].click(); return; } } } links = document.getElementsByTagName("link"); for (var i = links.length - 1; i > -1; i--) { if (links[i].hasAttribute("rel") && links[i].getAttribute("rel").match(regexp)) { if (debug) alert("<link rel=""> found"); links[i].click(); return; } } links = document.getElementsByTagName("a"); for (var i = links.length - 1; i > -1; i--) { if (links[i].textContent && links[i].textContent.match(regexp)) { links[i].click(); return; } } for (var i = links.length - 1; i > -1; i--) { var divs = links[i].getElementsByTagName("div"); for (var j = divs.length - 1; j > -1; j--) { if (divs[j].textContent && divs[j].textContent.match(regexp)) { links[i].click(); return; } } } for (var i = links.length - 1; i > -1; i--) { var spans = links[i].getElementsByTagName("span"); for (var j = spans.length - 1; j > -1; j--) { if (spans[j].textContent && spans[j].textContent.match(regexp)) { links[i].click(); return; } } }[/code]</span></a>


Log in to reply
 

Looks like your connection to Vivaldi Forum was lost, please wait while we try to reconnect.