aboutsummaryrefslogtreecommitdiffstats
path: root/google-plus-commando.js
diff options
context:
space:
mode:
authoranekos2011-08-04 23:56:12 +0900
committeranekos2011-08-04 23:56:12 +0900
commitad365c8fcb1dfde41ad028595516ce8f0ddfc175 (patch)
tree9c7e93b4dd8cce9a97267c65e083ad952a9b1163 /google-plus-commando.js
parentedd6cd96be6f8c0d73830ff41bdd6ad10d585707 (diff)
downloadvimperator-plugins-ad365c8fcb1dfde41ad028595516ce8f0ddfc175.tar.bz2
複数リンク対応
Diffstat (limited to 'google-plus-commando.js')
-rw-r--r--google-plus-commando.js45
1 files changed, 38 insertions, 7 deletions
diff --git a/google-plus-commando.js b/google-plus-commando.js
index dfdd2ef..b14c644 100644
--- a/google-plus-commando.js
+++ b/google-plus-commando.js
@@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
// INFO {{{
let INFO =
<>
- <plugin name="GooglePlusCommando" version="2.1.0"
+ <plugin name="GooglePlusCommando" version="2.1.1"
href="http://github.com/vimpr/vimperator-plugins/blob/master/google-plus-commando.js"
summary="The handy commands for Google+"
lang="en-US"
@@ -683,17 +683,48 @@ let g:gplus_commando_map_menu = "m"
click(Elements.currentEntry.menu.mute);
},
open: function () {
+ function clicks (links) {
+ if (links.length === 1)
+ return click(links[0]);
+
+ let t = {};
+ A(links).forEach(function (link) (t[link.textContent] = link));
+
+ commandline.input(
+ 'Selector a link',
+ function (url) {
+ let link = t[url];
+ if (link) {
+ click(link);
+ } else {
+ liberator.open(url, liberator.NEW_TAB);
+ }
+ },
+ {
+ completer: function (context) {
+ context.completions = [
+ [link.href, link.textContent]
+ for ([, link] in IA(links))
+ ];
+ }
+ }
+ );
+ }
+
let ce = Elements.currentEntry;
if (!ce)
return;
+
let dct = ce.root.querySelector('div[data-content-type]');
- let links = dct.parentNode.querySelectorAll('a');
- if (links.length < 1) {
- click(dct);
- return;
+ if (dct) {
+ let links = dct.parentNode.querySelectorAll('a');
+ if (links.length < 1)
+ return click(dct);
+ return clicks(links);
}
- if (links.length === 1)
- click(links[0]);
+
+ let links = ce.root.querySelectorAll('a.ot-anchor');
+ clicks(links);
}
};