summaryrefslogtreecommitdiff
path: root/ext/bg/js/search.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/search.js')
-rw-r--r--ext/bg/js/search.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 00b7ca4b..d2e0fd56 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -227,6 +227,7 @@ class DisplaySearch extends Display {
} else {
this.container.textContent = '';
}
+ this.setTitleText(query);
window.parent.postMessage('popupClose', '*');
} catch (e) {
this.onError(e);
@@ -356,6 +357,19 @@ class DisplaySearch extends Display {
this.search.disabled = this.introVisible && (this.query === null || this.query.value.length === 0);
}
+ setTitleText(text) {
+ // Chrome limits title to 1024 characters
+ if (text.length > 1000) {
+ text = text.substring(0, 1000) + '...';
+ }
+
+ if (text.length === 0) {
+ document.title = 'Yomichan Search';
+ } else {
+ document.title = `${text} - Yomichan Search`;
+ }
+ }
+
static getSearchQueryFromLocation(url) {
const match = /^[^?#]*\?(?:[^&#]*&)?query=([^&#]*)/.exec(url);
return match !== null ? decodeURIComponent(match[1]) : null;