aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-09-23 17:03:00 -0700
committerGitHub <noreply@github.com>2019-09-23 17:03:00 -0700
commitba2858309ee5646ee25e85caae681937647e419b (patch)
tree60936bf08b4c908eb6a6f287bec4ddb53f7ba2a6 /ext/fg/js/frontend.js
parentdb405ffd240b8266e6b1585415ed1e90b629bc3e (diff)
parent352d214203fba929594c6139189fa59c6772c69f (diff)
Merge pull request #218 from toasted-nutbread/settings-profile-conditions
Settings profile conditions
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 564df343..167e82c0 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -27,7 +27,8 @@ class Frontend {
this.ignoreNodes = (Array.isArray(ignoreNodes) && ignoreNodes.length > 0 ? ignoreNodes.join(',') : null);
this.optionsContext = {
- depth: popup.depth
+ depth: popup.depth,
+ url: popup.url
};
this.primaryTouchIdentifier = null;
@@ -42,9 +43,9 @@ class Frontend {
static create() {
const initializationData = window.frontendInitializationData;
const isNested = (initializationData !== null && typeof initializationData === 'object');
- const {id, depth, parentFrameId, ignoreNodes} = isNested ? initializationData : {};
+ const {id, depth, parentFrameId, ignoreNodes, url} = isNested ? initializationData : {};
- const popup = isNested ? new PopupProxy(depth + 1, id, parentFrameId) : PopupProxyHost.instance.createPopup(null);
+ const popup = isNested ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null);
const frontend = new Frontend(popup, ignoreNodes);
frontend.prepare();
return frontend;
@@ -52,7 +53,7 @@ class Frontend {
async prepare() {
try {
- this.options = await apiOptionsGet(this.optionsContext);
+ this.options = await apiOptionsGet(this.getOptionsContext());
window.addEventListener('message', this.onFrameMessage.bind(this));
window.addEventListener('mousedown', this.onMouseDown.bind(this));
@@ -262,7 +263,7 @@ class Frontend {
}
async updateOptions() {
- this.options = await apiOptionsGet(this.optionsContext);
+ this.options = await apiOptionsGet(this.getOptionsContext());
if (!this.options.enable) {
this.searchClear();
}
@@ -335,7 +336,7 @@ class Frontend {
return;
}
- const {definitions, length} = await apiTermsFind(searchText, this.optionsContext);
+ const {definitions, length} = await apiTermsFind(searchText, this.getOptionsContext());
if (definitions.length === 0) {
return false;
}
@@ -368,7 +369,7 @@ class Frontend {
return;
}
- const definitions = await apiKanjiFind(searchText, this.optionsContext);
+ const definitions = await apiKanjiFind(searchText, this.getOptionsContext());
if (definitions.length === 0) {
return false;
}
@@ -512,6 +513,11 @@ class Frontend {
}
}
+ getOptionsContext() {
+ this.optionsContext.url = this.popup.url;
+ return this.optionsContext;
+ }
+
static isScanningModifierPressed(scanningModifier, mouseEvent) {
switch (scanningModifier) {
case 'alt': return mouseEvent.altKey;