summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-12-06 00:40:41 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2019-12-06 00:40:41 +0200
commit14c5857dfe58eb14599438f8cfb8d436d38e2006 (patch)
tree2a94817eb324bc9243ef7595d344367bc8f859d2 /ext/bg
parent248b0f15eb7d0fd10d3678a2e5d2f6ddb631309f (diff)
set title text on search page
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/search.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 00b7ca4b..fe48773f 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -224,6 +224,7 @@ class DisplaySearch extends Display {
sentence: {text: query, offset: 0},
url: window.location.href
});
+ this.setTitleText(query);
} else {
this.container.textContent = '';
}
@@ -356,6 +357,14 @@ 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.slice(0, 1000) + '...';
+ }
+ document.title = `${text} - Yomichan Search`;
+ }
+
static getSearchQueryFromLocation(url) {
const match = /^[^?#]*\?(?:[^&#]*&)?query=([^&#]*)/.exec(url);
return match !== null ? decodeURIComponent(match[1]) : null;