aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/float.js8
-rw-r--r--ext/fg/js/frontend.js20
-rw-r--r--ext/fg/js/popup-nested.js6
-rw-r--r--ext/fg/js/popup-proxy.js3
-rw-r--r--ext/fg/js/popup.js7
5 files changed, 29 insertions, 15 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 348c114e..fd7986b8 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -24,7 +24,8 @@ class DisplayFloat extends Display {
this.styleNode = null;
this.optionsContext = {
- depth: 0
+ depth: 0,
+ url: window.location.href
};
this.dependencies = Object.assign({}, this.dependencies, {docRangeFromPoint, docSentenceExtract});
@@ -78,9 +79,10 @@ class DisplayFloat extends Display {
}
},
- popupNestedInitialize: ({id, depth, parentFrameId}) => {
+ popupNestedInitialize: ({id, depth, parentFrameId, url}) => {
this.optionsContext.depth = depth;
- popupNestedInitialize(id, depth, parentFrameId);
+ this.optionsContext.url = url;
+ popupNestedInitialize(id, depth, parentFrameId, url);
}
};
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;
diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js
index de2acccc..b36de2ec 100644
--- a/ext/fg/js/popup-nested.js
+++ b/ext/fg/js/popup-nested.js
@@ -19,13 +19,13 @@
let popupNestedInitialized = false;
-async function popupNestedInitialize(id, depth, parentFrameId) {
+async function popupNestedInitialize(id, depth, parentFrameId, url) {
if (popupNestedInitialized) {
return;
}
popupNestedInitialized = true;
- const optionsContext = {depth};
+ const optionsContext = {depth, url};
const options = await apiOptionsGet(optionsContext);
const popupNestingMaxDepth = options.scanning.popupNestingMaxDepth;
@@ -35,7 +35,7 @@ async function popupNestedInitialize(id, depth, parentFrameId) {
const ignoreNodes = options.scanning.enableOnPopupExpressions ? [] : [ '.expression', '.expression *' ];
- window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes};
+ window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url};
const scriptSrcs = [
'/fg/js/frontend-api-sender.js',
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index f04e24e0..235e1730 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -18,7 +18,7 @@
class PopupProxy {
- constructor(depth, parentId, parentFrameId) {
+ constructor(depth, parentId, parentFrameId, url) {
this.parentId = parentId;
this.parentFrameId = parentFrameId;
this.id = null;
@@ -26,6 +26,7 @@ class PopupProxy {
this.parent = null;
this.child = null;
this.depth = depth;
+ this.url = url;
this.container = null;
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 8953cf30..08965084 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -59,7 +59,8 @@ class Popup {
this.invokeApi('popupNestedInitialize', {
id: this.id,
depth: this.depth,
- parentFrameId
+ parentFrameId,
+ url: this.url
});
this.invokeApi('setOptions', {
general: {
@@ -311,4 +312,8 @@ class Popup {
parent.appendChild(this.container);
}
}
+
+ get url() {
+ return window.location.href;
+ }
}