mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Add clicknext functionality for comics etc
This commit is contained in:
parent
85e8b82c88
commit
6ca754dd9f
3 changed files with 21 additions and 12 deletions
|
@ -195,6 +195,7 @@ export function open(url: string) {
|
|||
url = (hasScheme(url)? "" : "http://") + url
|
||||
messageActiveTab("open", [url])
|
||||
}
|
||||
export function clicknext(dir = "next") {messageActiveTab("clicknext",[dir])}
|
||||
|
||||
// Hard coded search but lack thereof was annoying
|
||||
export function google(query: string[]){
|
||||
|
|
|
@ -45,23 +45,30 @@ const commands = new Map<string, ContentCommand>([
|
|||
function hidecommandline() {
|
||||
CommandLineContent.hide()
|
||||
},
|
||||
function follow-next(){
|
||||
// Vimperator just clicks first a tag that matches below
|
||||
// 'nextpattern'stringlist(default: \bnext,^>$,^(>>|»)$,^(>|»),(>|»)$,\bmore\b)
|
||||
},
|
||||
// Todo - send message to background
|
||||
function getCurrentURL(){
|
||||
function getcurrentURL(){
|
||||
return window.location.href
|
||||
,
|
||||
function getLinks(){
|
||||
return document.getElementsByTagName('a')
|
||||
}
|
||||
function clickNext(next = true){
|
||||
// filter getlinks .innerhtml for something like vimerator
|
||||
},
|
||||
function clicknext(dir = "next"){
|
||||
let linkarray = Array.from(getlinks())
|
||||
// The desired one
|
||||
let regarray = [/\bnext|^>$|^(>>|»)$|^(>|»)|(>|»)$|\bmore\b/i, /\bprev\b|\bprevious\b|^<$|^(<<|«)$|^(<|«)|(<|«)$/i]
|
||||
|
||||
// RPS is hardcoded because it never worked in Vimperator and it always annoyed me
|
||||
regarray = window.location.href.match(/rockpapershotgun/) ? [/newer/i,/older/i] : regarray
|
||||
|
||||
let nextreg = (dir == "next") ? regarray[0] : regarray[1]
|
||||
|
||||
// Might need to add more cases to this as we look at more sites
|
||||
let nextlinks = linkarray.filter((link) => (link.innerText.match(nextreg) || link.rel.match(nextreg)))
|
||||
window.location.href = nextlinks[0].href
|
||||
}
|
||||
].map((command):any => [command.name, command]))
|
||||
|
||||
function getlinks(){
|
||||
return document.getElementsByTagName('a')
|
||||
}
|
||||
|
||||
function messageReceiver(message: Message) {
|
||||
if (message.type === "excmd_contentcommand") {
|
||||
console.log(message)
|
||||
|
|
|
@ -35,7 +35,8 @@ export namespace normalmode {
|
|||
["W", "current-url winopen"],
|
||||
["t", "tabopen"],
|
||||
//["t", "showcommandline tabopen"], // for now, use mozilla completion
|
||||
["]]", "follow-next"],
|
||||
["]]", "clicknext"],
|
||||
["[[", "clicknext prev"],
|
||||
["T", "current-url tab"],
|
||||
["j", "scrollline 10"],
|
||||
["k", "scrollline -10"],
|
||||
|
|
Loading…
Add table
Reference in a new issue