diff options
| author | anekos | 2011-08-04 23:56:12 +0900 | 
|---|---|---|
| committer | anekos | 2011-08-04 23:56:12 +0900 | 
| commit | ad365c8fcb1dfde41ad028595516ce8f0ddfc175 (patch) | |
| tree | 9c7e93b4dd8cce9a97267c65e083ad952a9b1163 | |
| parent | edd6cd96be6f8c0d73830ff41bdd6ad10d585707 (diff) | |
| download | vimperator-plugins-ad365c8fcb1dfde41ad028595516ce8f0ddfc175.tar.bz2 | |
複数リンク対応
| -rw-r--r-- | google-plus-commando.js | 45 | 
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);      }    };  | 
