summaryrefslogtreecommitdiff
path: root/ext/js/app/frontend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/app/frontend.js')
-rw-r--r--ext/js/app/frontend.js42
1 files changed, 12 insertions, 30 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js
index e386bf64..9dafde7a 100644
--- a/ext/js/app/frontend.js
+++ b/ext/js/app/frontend.js
@@ -178,11 +178,11 @@ export class Frontend {
/* eslint-disable no-multi-spaces */
yomitan.crossFrame.registerHandlers([
- ['Frontend.closePopup', this._onApiClosePopup.bind(this)],
- ['Frontend.copySelection', this._onApiCopySelection.bind(this)],
- ['Frontend.getSelectionText', this._onApiGetSelectionText.bind(this)],
- ['Frontend.getPopupInfo', this._onApiGetPopupInfo.bind(this)],
- ['Frontend.getPageInfo', this._onApiGetPageInfo.bind(this)]
+ ['frontendClosePopup', this._onApiClosePopup.bind(this)],
+ ['frontendCopySelection', this._onApiCopySelection.bind(this)],
+ ['frontendGetSelectionText', this._onApiGetSelectionText.bind(this)],
+ ['frontendGetPopupInfo', this._onApiGetPopupInfo.bind(this)],
+ ['frontendGetPageInfo', this._onApiGetPageInfo.bind(this)]
]);
/* eslint-enable no-multi-spaces */
@@ -263,48 +263,31 @@ export class Frontend {
// API message handlers
- /**
- * @returns {string}
- */
- _onApiGetUrl() {
- return window.location.href;
- }
-
- /**
- * @returns {void}
- */
+ /** @type {import('cross-frame-api').ApiHandler<'frontendClosePopup'>} */
_onApiClosePopup() {
this._clearSelection(false);
}
- /**
- * @returns {void}
- */
+ /** @type {import('cross-frame-api').ApiHandler<'frontendCopySelection'>} */
_onApiCopySelection() {
// This will not work on Firefox if a popup has focus, which is usually the case when this function is called.
document.execCommand('copy');
}
- /**
- * @returns {string}
- */
+ /** @type {import('cross-frame-api').ApiHandler<'frontendGetSelectionText'>} */
_onApiGetSelectionText() {
const selection = document.getSelection();
return selection !== null ? selection.toString() : '';
}
- /**
- * @returns {import('frontend').GetPopupInfoResult}
- */
+ /** @type {import('cross-frame-api').ApiHandler<'frontendGetPopupInfo'>} */
_onApiGetPopupInfo() {
return {
popupId: (this._popup !== null ? this._popup.id : null)
};
}
- /**
- * @returns {{url: string, documentTitle: string}}
- */
+ /** @type {import('cross-frame-api').ApiHandler<'frontendGetPageInfo'>} */
_onApiGetPageInfo() {
return {
url: window.location.href,
@@ -620,8 +603,7 @@ export class Frontend {
return await this._getDefaultPopup();
}
- /** @type {import('frontend').GetPopupInfoResult} */
- const {popupId} = await yomitan.crossFrame.invoke(targetFrameId, 'Frontend.getPopupInfo', {});
+ const {popupId} = await yomitan.crossFrame.invoke(targetFrameId, 'frontendGetPopupInfo', void 0);
if (popupId === null) {
return null;
}
@@ -905,7 +887,7 @@ export class Frontend {
let documentTitle = document.title;
if (this._useProxyPopup && this._parentFrameId !== null) {
try {
- ({url, documentTitle} = await yomitan.crossFrame.invoke(this._parentFrameId, 'Frontend.getPageInfo', {}));
+ ({url, documentTitle} = await yomitan.crossFrame.invoke(this._parentFrameId, 'frontendGetPageInfo', void 0));
} catch (e) {
// NOP
}