aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/search.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-19 22:28:23 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-19 22:28:23 -0400
commitdbec4bffda00615fe768f66c1eb5d895aea05585 (patch)
tree54dccc8a6b9d73b67d990b8be59d3c38604de027 /ext/bg/js/search.js
parenta5d7de8e97400f63c328ccde9b313a127cef0611 (diff)
Make the search button reuse an open search tab if it exists
Diffstat (limited to 'ext/bg/js/search.js')
-rw-r--r--ext/bg/js/search.js17
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();