diff options
author | anekos | 2010-06-21 16:28:14 +0000 |
---|---|---|
committer | anekos | 2010-06-21 16:28:14 +0000 |
commit | 55261cd431d7ec96e8cd76e49e47539f9a4b355c (patch) | |
tree | 3311c1fe3189a6a187f3b44ec48e2f2f725be965 /forcefocuscontent.js | |
parent | 8b66fec79c28926404f2e7ec6864c36847949b51 (diff) | |
download | vimperator-plugins-55261cd431d7ec96e8cd76e49e47539f9a4b355c.tar.bz2 |
オプション値 u を追加
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37851 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'forcefocuscontent.js')
-rw-r--r-- | forcefocuscontent.js | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/forcefocuscontent.js b/forcefocuscontent.js index e8a5d3e..7c97029 100644 --- a/forcefocuscontent.js +++ b/forcefocuscontent.js @@ -11,16 +11,39 @@ var PLUGIN_INFO = </VimperatorPlugin>; //}}} +if (__context__.__addedEventListener) + getBrowser().removeEventListener("load", __context__.__addedEventListener, true); + getBrowser().addEventListener("load", onPageLoad, true); + function onPageLoad(event) { + try { let doc = event.originalTarget; if (doc != getBrowser().contentDocument) return; - setTimeout(function () { - let focused = document.commandDispatcher.focusedElement; - if (focused) - focused.blur(); - }, 100); + + let eproto = doc.defaultView.wrappedJSObject.HTMLInputElement.prototype; + let original = eproto.focus; + + let ignore = function () { return void 0; }; + let remove = function () { + liberator.log('removed'); + eproto.focus = original; + if (handle) + clearTimeout(handle); + }; + + doc.defaultView.wrappedJSObject.HTMLInputElement.prototype.focus = ignore; + + //let handle = setTimeout(remove, 5000); + + liberator.log('injected'); + } catch (e) { + liberator.log(e); + } } + +__context__.__addedEventListener = onPageLoad; + // vim: fdm=marker sw=4 ts=4 et: |