diff options
author | Alex Yatskov <FooSoft@users.noreply.github.com> | 2019-10-20 11:06:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-20 11:06:23 -0700 |
commit | d8f9c2e1d43a7c37103d7f9a58039bffa4aac495 (patch) | |
tree | dca6abf8ef84eb8cc714ad1f5e78a24a6dbaa21c /ext/bg/js/search.js | |
parent | 65923238556212fef2d7ed7a156373c88382ffd2 (diff) | |
parent | 362a1ed9e4621c47b4dca99777015b90fc90451c (diff) |
Merge pull request #261 from toasted-nutbread/search-button-reuse-tab
Reuse open search tab when clicking search button
Diffstat (limited to 'ext/bg/js/search.js')
-rw-r--r-- | ext/bg/js/search.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index a5a815cf..431478c9 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -114,6 +114,17 @@ class DisplaySearch extends Display { } } + onRuntimeMessage({action, params}, sender, callback) { + const handlers = DisplaySearch.runtimeMessageHandlers; + if (handlers.hasOwnProperty(action)) { + const handler = handlers[action]; + const result = handler(this, params); + callback(result); + } else { + return super.onRuntimeMessage({action, params}, sender, callback); + } + } + getOptionsContext() { return this.optionsContext; } @@ -188,4 +199,10 @@ class DisplaySearch extends Display { } } +DisplaySearch.runtimeMessageHandlers = { + getUrl: () => { + return {url: window.location.href}; + } +}; + window.yomichan_search = DisplaySearch.create(); |