diff options
author | anekos | 2011-07-13 09:53:54 +0900 |
---|---|---|
committer | anekos | 2011-07-13 09:55:50 +0900 |
commit | 6efe2430a6e93bcab9817c5abdc3019e8c17229f (patch) | |
tree | c3fa5a9db1ffa7c09824ef5c9c60f8471019226b | |
parent | ede4a6aae75c788b879e794c610eeb7ec135b76a (diff) | |
download | vimperator-plugins-6efe2430a6e93bcab9817c5abdc3019e8c17229f.tar.bz2 |
拡大表示的なときに、余計なヒントを表示しないようにするんだ
-rw-r--r-- | google-plus-commando.js | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/google-plus-commando.js b/google-plus-commando.js index b93e3fe..49cb99e 100644 --- a/google-plus-commando.js +++ b/google-plus-commando.js @@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE. // INFO {{{ let INFO = <> - <plugin name="GooglePlusCommando" version="1.1.1" + <plugin name="GooglePlusCommando" version="1.2.0" href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/google-plus-commando.js" summary="The handy commands for Google+" lang="en-US" @@ -67,6 +67,7 @@ let INFO = }; } + const Conf = (function () { let gv = liberator.globalVariables; let conf = {}; @@ -91,7 +92,8 @@ let INFO = Elements.postForm.querySelector('.editable').parentNode ), get submitButton () Elements.postForm.querySelector('[role="button"]'), - get notification () Elements.doc.querySelector('#gbi1') + get notification () Elements.doc.querySelector('#gbi1'), + get screen () Elements.doc.querySelector('.zg') }; function Entry (root) { @@ -179,19 +181,48 @@ let INFO = ); }); - if (plugins.xHint) { + + [ + ['o', 'f', function (e) click(e)], + ['t', 'F', function (e) buffer.followLink(e, liberator.NEW_TAB)], + ].forEach(function ([modeChar, mapKey, action]) { + let modeName = 'google-plus-comando-hint-' + modeChar; + + hints.addMode( + modeName, + hints._hintModes[modeChar].prompt, + action, + function () { + function removeRoot (s) + s.replace(/^\s*\/\//, ''); + + const ext = [ + 'span[@role="button"]', + 'div[@role="button"]', + 'div[@data-content-type]' + ]; + + let xpath = options['hinttags'].split(/\s*\|\s*/).map(removeRoot).concat(ext); + + if (Elements.screen) { + xpath.push('div[contains(@class, "CH")]'); + xpath = xpath.map(function (it) '*[@class="zg"]//' + it) + } + + return xpath.map(function (it) '//' + it).join(' | '); + } + ); + mappings.addUserMap( [modes.NORMAL], - ['f'], + [liberator.globalVariables['gplus_commando_map_hint_' + modeChar] || mapKey], 'Hit a hint - Google plus Commando', - function () { - plugins.xHint.show('o', options['hinttags'] + ' | //span[@role="button"] | //div[@role="button"]'); - }, + function () hints.show(modeName), { matchingUrls: RegExp('^https://plus\\.google\\.com/*') } ); - } + }); __context__.command = Commands; __context__.element = Elements; |