| 76 | | liberator.commands.addUserCommand( |
| 77 | | ['fo[pen]', 'filteropen'], |
| 78 | | 'Filtered open', |
| 79 | | function (opts, bang) { |
| 80 | | let where = charToWhere(opts['-where'], bang ? NEW_TAB : NEW_BACKGROUND_TAB); |
| 81 | | let [i, links] = [1, filteredLinks(opts.arguments.join(''))]; |
| 82 | | if (!links.length) |
| 83 | | return; |
| 84 | | open(links[0].href, where); |
| 85 | | if (links.length <= 1) |
| 86 | | return; |
| 87 | | let interval = (opts['-interval'] || liberator.globalVariables.fopen_default_interval || 1) * 1000; |
| 88 | | foihandle = setInterval(function () { |
| 89 | | try { |
| 90 | | open(links[i].href, where); |
| 91 | | if ((++i) >= links.length) |
| | 72 | |
| | 73 | let (foihandle) { |
| | 74 | |
| | 75 | liberator.commands.addUserCommand( |
| | 76 | ['fo[pen]', 'filteropen'], |
| | 77 | 'Filtered open', |
| | 78 | function (opts, bang) { |
| | 79 | let where = charToWhere(opts['-where'], bang ? NEW_TAB : NEW_BACKGROUND_TAB); |
| | 80 | let [i, links] = [1, filteredLinks(opts.arguments.join(''))]; |
| | 81 | if (!links.length) |
| | 82 | return; |
| | 83 | open(links[0].href, where); |
| | 84 | if (links.length <= 1) |
| | 85 | return; |
| | 86 | let interval = (opts['-interval'] || liberator.globalVariables.fopen_default_interval || 1) * 1000; |
| | 87 | foihandle = setInterval(function () { |
| | 88 | try { |
| | 89 | open(links[i].href, where); |
| | 90 | if ((++i) >= links.length) |
| | 91 | clearInterval(foihandle); |
| | 92 | } catch (e) { |
| 93 | | } catch (e) { |
| 94 | | clearInterval(foihandle); |
| | 94 | } |
| | 95 | }, interval); |
| | 96 | }, |
| | 97 | { |
| | 98 | bang: true, |
| | 99 | options: [ |
| | 100 | [['-interval', '-i'], liberator.commands.OPTION_INT], |
| | 101 | [['-where', '-w'], liberator.commands.OPTION_STRING], |
| | 102 | ], |
| | 103 | completer: function (word) { |
| | 104 | let links = filteredLinks(word); |
| | 105 | return [0, [[it.href, it.textContent] for each (it in links)]]; |
| | 106 | }, |
| | 107 | } |
| | 108 | ); |
| | 109 | |
| | 110 | liberator.commands.addUserCommand( |
| | 111 | ['stopfilteropen', 'stopfo[pen]'], |
| | 112 | 'Stop filtered open', |
| | 113 | function () { |
| | 114 | clearInterval(foihandle); |
| | 115 | } |
| | 116 | ); |
| | 117 | |
| | 118 | } |
| | 119 | |
| | 120 | let ( |
| | 121 | lolinks = [], |
| | 122 | looptions = [ [['-where', '-w'], liberator.commands.OPTION_STRING, null, WHERE_COMPLETIONS] ] |
| | 123 | ) { |
| | 124 | |
| | 125 | liberator.commands.addUserCommand( |
| | 126 | ['lo[pen]', 'linkopen'], |
| | 127 | 'Filtered open', |
| | 128 | function (opts, bang) { |
| | 129 | let where = charToWhere(opts['-where'], bang ? NEW_TAB : CURRENT_TAB); |
| | 130 | let arg = opts.arguments[0]; |
| | 131 | let m = arg.match(/^(\d+),/); |
| | 132 | if (m) |
| | 133 | liberator.buffer.followLink(lolinks[parseInt(m[1], 10)], where); |
| | 134 | }, |
| | 135 | { |
| | 136 | options: looptions, |
| | 137 | bang: true, |
| | 138 | completer: function (word) { |
| | 139 | if (!word || word.match(/\d+,|\s/)) |
| | 140 | return []; |
| | 141 | lolinks = filteredLinks(word); |
| | 142 | return [0, [[i + ',' + lolinks[i].href, lolinks[i].textContent] for (i in lolinks || [])]]; |
| 96 | | }, interval); |
| 97 | | }, |
| 98 | | { |
| 99 | | options: [ |
| 100 | | [['-interval', '-i'], liberator.commands.OPTIONS_INT], |
| 101 | | [['-where', '-w'], liberator.commands.OPTIONS_STRING], |
| 102 | | ], |
| 103 | | completer: function (word) { |
| 104 | | let links = filteredLinks(word); |
| 105 | | return [0, [[it.href, it.textContent] for each (it in links)]]; |
| 110 | | liberator.commands.addUserCommand( |
| 111 | | ['stopfilteropen', 'stopfo[pen]'], |
| 112 | | 'Stop filtered open', |
| 113 | | function () { |
| 114 | | clearInterval(foihandle); |
| 115 | | } |
| 116 | | ); |
| 117 | | |
| 118 | | let lolinks = []; |
| 119 | | let looptions = [ [['-where', '-w'], liberator.commands.OPTIONS_STRING], ]; |
| 120 | | |
| 121 | | liberator.commands.addUserCommand( |
| 122 | | ['lo[pen]', 'linkopen'], |
| 123 | | 'Filtered open', |
| 124 | | function (opts, bang) { |
| 125 | | let where = charToWhere(opts['-where'], bang ? NEW_TAB : CURRENT_TAB); |
| 126 | | let uri = opts.arguments[0]; |
| 127 | | for each (let link in lolinks) { |
| 128 | | if (~link.href.indexOf(uri)) |
| 129 | | return liberator.buffer.followLink(link, where); |
| 130 | | } |
| 131 | | if (lolinks[0]) { |
| 132 | | liberator.buffer.followLink(lolinks[0], where); |
| 133 | | } else { |
| 134 | | liberator.echoerr('lol'); |
| 135 | | } |
| 136 | | }, |
| 137 | | { |
| 138 | | options: looptions, |
| 139 | | completer: function (word) { |
| 140 | | let opts = liberator.parseArgs(word, looptions, "1", true); |
| 141 | | log(opts); |
| 142 | | lolinks = filteredLinks(word);//word.match(/\bhttp\S+/)); |
| 143 | | return [0, [[it.href, it.textContent] for each (it in lolinks)]]; |
| 144 | | } |
| 145 | | } |
| 146 | | ); |
| | 147 | } |