summaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/content-script-main.js13
-rw-r--r--ext/fg/js/float-main.js7
-rw-r--r--ext/fg/js/float.js11
-rw-r--r--ext/fg/js/frame-offset-forwarder.js4
-rw-r--r--ext/fg/js/frontend.js18
-rw-r--r--ext/fg/js/popup.js4
6 files changed, 24 insertions, 33 deletions
diff --git a/ext/fg/js/content-script-main.js b/ext/fg/js/content-script-main.js
index 57386b85..b057ae3d 100644
--- a/ext/fg/js/content-script-main.js
+++ b/ext/fg/js/content-script-main.js
@@ -21,10 +21,7 @@
* Frontend
* PopupFactory
* PopupProxy
- * apiBroadcastTab
- * apiForwardLogsToBackend
- * apiFrameInformationGet
- * apiOptionsGet
+ * api
*/
async function createIframePopupProxy(frameOffsetForwarder, setDisabled) {
@@ -36,7 +33,7 @@ async function createIframePopupProxy(frameOffsetForwarder, setDisabled) {
}
}
);
- apiBroadcastTab('rootPopupRequestInformationBroadcast');
+ api.broadcastTab('rootPopupRequestInformationBroadcast');
const {popupId, frameId: parentFrameId} = await rootPopupInformationPromise;
const getFrameOffset = frameOffsetForwarder.getOffset.bind(frameOffsetForwarder);
@@ -48,7 +45,7 @@ async function createIframePopupProxy(frameOffsetForwarder, setDisabled) {
}
async function getOrCreatePopup(depth) {
- const {frameId} = await apiFrameInformationGet();
+ const {frameId} = await api.frameInformationGet();
if (typeof frameId !== 'number') {
const error = new Error('Failed to get frameId');
yomichan.logError(error);
@@ -71,7 +68,7 @@ async function createPopupProxy(depth, id, parentFrameId) {
}
(async () => {
- apiForwardLogsToBackend();
+ api.forwardLogsToBackend();
await yomichan.prepare();
const data = window.frontendInitializationData || {};
@@ -112,7 +109,7 @@ async function createPopupProxy(depth, id, parentFrameId) {
depth: isSearchPage ? 0 : depth,
url: proxy ? await getPopupProxyUrl() : window.location.href
};
- const options = await apiOptionsGet(optionsContext);
+ const options = await api.optionsGet(optionsContext);
if (!proxy && frameOffsetForwarder === null) {
frameOffsetForwarder = new FrameOffsetForwarder();
diff --git a/ext/fg/js/float-main.js b/ext/fg/js/float-main.js
index 20771910..249b4dbe 100644
--- a/ext/fg/js/float-main.js
+++ b/ext/fg/js/float-main.js
@@ -17,8 +17,7 @@
/* global
* DisplayFloat
- * apiForwardLogsToBackend
- * apiOptionsGet
+ * api
* dynamicLoader
*/
@@ -38,7 +37,7 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) {
const applyOptions = async () => {
const optionsContext = {depth, url};
- const options = await apiOptionsGet(optionsContext);
+ const options = await api.optionsGet(optionsContext);
const maxPopupDepthExceeded = !(typeof depth === 'number' && depth < options.scanning.popupNestingMaxDepth);
if (maxPopupDepthExceeded || optionsApplied) { return; }
@@ -55,7 +54,7 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) {
}
(async () => {
- apiForwardLogsToBackend();
+ api.forwardLogsToBackend();
const display = new DisplayFloat();
await display.prepare();
})();
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 845bf7f6..12d27a9f 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -17,8 +17,7 @@
/* global
* Display
- * apiBroadcastTab
- * apiSendMessageToFrame
+ * api
* popupNestedInitialize
*/
@@ -61,7 +60,7 @@ class DisplayFloat extends Display {
yomichan.on('orphaned', this.onOrphaned.bind(this));
window.addEventListener('message', this.onMessage.bind(this), false);
- apiBroadcastTab('popupPrepared', {secret: this._secret});
+ api.broadcastTab('popupPrepared', {secret: this._secret});
}
onError(error) {
@@ -153,7 +152,7 @@ class DisplayFloat extends Display {
},
2000
);
- apiBroadcastTab('requestDocumentInformationBroadcast', {uniqueId});
+ api.broadcastTab('requestDocumentInformationBroadcast', {uniqueId});
const {title} = await promise;
return title;
@@ -176,7 +175,7 @@ class DisplayFloat extends Display {
const {token, frameId} = params;
this._token = token;
- apiSendMessageToFrame(frameId, 'popupInitialized', {secret, token});
+ api.sendMessageToFrame(frameId, 'popupInitialized', {secret, token});
}
async _configure({messageId, frameId, popupId, optionsContext, childrenSupported, scale}) {
@@ -192,7 +191,7 @@ class DisplayFloat extends Display {
this.setContentScale(scale);
- apiSendMessageToFrame(frameId, 'popupConfigured', {messageId});
+ api.sendMessageToFrame(frameId, 'popupConfigured', {messageId});
}
_isMessageAuthenticated(message) {
diff --git a/ext/fg/js/frame-offset-forwarder.js b/ext/fg/js/frame-offset-forwarder.js
index 9b68d34e..10e3b5be 100644
--- a/ext/fg/js/frame-offset-forwarder.js
+++ b/ext/fg/js/frame-offset-forwarder.js
@@ -16,7 +16,7 @@
*/
/* global
- * apiBroadcastTab
+ * api
*/
class FrameOffsetForwarder {
@@ -161,6 +161,6 @@ class FrameOffsetForwarder {
}
_forwardFrameOffsetOrigin(offset, uniqueId) {
- apiBroadcastTab('frameOffset', {offset, uniqueId});
+ api.broadcastTab('frameOffset', {offset, uniqueId});
}
}
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 575dc413..a263f3e6 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -17,11 +17,7 @@
/* global
* TextScanner
- * apiBroadcastTab
- * apiGetZoom
- * apiKanjiFind
- * apiOptionsGet
- * apiTermsFind
+ * api
* docSentenceExtract
*/
@@ -69,7 +65,7 @@ class Frontend {
async prepare() {
try {
await this.updateOptions();
- const {zoomFactor} = await apiGetZoom();
+ const {zoomFactor} = await api.getZoom();
this._pageZoomFactor = zoomFactor;
window.addEventListener('resize', this._onResize.bind(this), false);
@@ -120,7 +116,7 @@ class Frontend {
async updateOptions() {
const optionsContext = await this.getOptionsContext();
- this._options = await apiOptionsGet(optionsContext);
+ this._options = await api.optionsGet(optionsContext);
this._textScanner.setOptions(this._options);
this._updateTextScannerEnabled();
@@ -261,7 +257,7 @@ class Frontend {
const searchText = this._textScanner.getTextSourceContent(textSource, this._options.scanning.length);
if (searchText.length === 0) { return null; }
- const {definitions, length} = await apiTermsFind(searchText, {}, optionsContext);
+ const {definitions, length} = await api.termsFind(searchText, {}, optionsContext);
if (definitions.length === 0) { return null; }
textSource.setEndOffset(length);
@@ -273,7 +269,7 @@ class Frontend {
const searchText = this._textScanner.getTextSourceContent(textSource, 1);
if (searchText.length === 0) { return null; }
- const definitions = await apiKanjiFind(searchText, optionsContext);
+ const definitions = await api.kanjiFind(searchText, optionsContext);
if (definitions.length === 0) { return null; }
textSource.setEndOffset(1);
@@ -351,12 +347,12 @@ class Frontend {
_broadcastRootPopupInformation() {
if (!this._popup.isProxy() && this._popup.depth === 0 && this._popup.frameId === 0) {
- apiBroadcastTab('rootPopupInformation', {popupId: this._popup.id, frameId: this._popup.frameId});
+ api.broadcastTab('rootPopupInformation', {popupId: this._popup.id, frameId: this._popup.frameId});
}
}
_broadcastDocumentInformation(uniqueId) {
- apiBroadcastTab('documentInformationBroadcast', {
+ api.broadcastTab('documentInformationBroadcast', {
uniqueId,
frameId: this._popup.frameId,
title: document.title
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index b7d4b57e..a8188143 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -17,7 +17,7 @@
/* global
* DOM
- * apiOptionsGet
+ * api
* dynamicLoader
*/
@@ -89,7 +89,7 @@ class Popup {
this._optionsContext = optionsContext;
this._previousOptionsContextSource = source;
- this._options = await apiOptionsGet(optionsContext);
+ this._options = await api.optionsGet(optionsContext);
this.updateTheme();
this._invokeApi('setOptionsContext', {optionsContext});