summaryrefslogtreecommitdiff
path: root/ext/fg/js/float.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-07 19:00:58 -0400
committerGitHub <noreply@github.com>2020-04-07 19:00:58 -0400
commitfa68a8773605ee0943e1c5e9766fa6bcfb6c6a42 (patch)
tree3ac714d3b485b1a1b6b349f48a91a67045256f81 /ext/fg/js/float.js
parent3df78904cf734da208c6fd1b6ae1cd6612323148 (diff)
parent29cf8d2f79f23b7723d508085ca242396bbbd5c9 (diff)
Merge pull request #415 from toasted-nutbread/anki-marker-document-title
Anki marker document title
Diffstat (limited to 'ext/fg/js/float.js')
-rw-r--r--ext/fg/js/float.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 9b720ebe..01055ca6 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -162,6 +162,33 @@ class DisplayFloat extends Display {
setContentScale(scale) {
document.body.style.fontSize = `${scale}em`;
}
+
+ async getDocumentTitle() {
+ try {
+ const uniqueId = yomichan.generateId(16);
+
+ const promise = yomichan.getTemporaryListenerResult(
+ chrome.runtime.onMessage,
+ ({action, params}, {resolve}) => {
+ if (
+ action === 'documentInformationBroadcast' &&
+ isObject(params) &&
+ params.uniqueId === uniqueId &&
+ params.frameId === 0
+ ) {
+ resolve(params);
+ }
+ },
+ 2000
+ );
+ apiForward('requestDocumentInformationBroadcast', {uniqueId});
+
+ const {title} = await promise;
+ return title;
+ } catch (e) {
+ return '';
+ }
+ }
}
DisplayFloat.instance = new DisplayFloat();