aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/api.js28
-rw-r--r--ext/mixed/js/core.js9
-rw-r--r--ext/mixed/js/text-scanner.js12
3 files changed, 39 insertions, 10 deletions
diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js
index 50b285a5..7080d93a 100644
--- a/ext/mixed/js/api.js
+++ b/ext/mixed/js/api.js
@@ -44,10 +44,6 @@ function apiTextParse(text, optionsContext) {
return _apiInvoke('textParse', {text, optionsContext});
}
-function apiTextParseMecab(text, optionsContext) {
- return _apiInvoke('textParseMecab', {text, optionsContext});
-}
-
function apiKanjiFind(text, optionsContext) {
return _apiInvoke('kanjiFind', {text, optionsContext});
}
@@ -120,6 +116,30 @@ function apiGetDefaultAnkiFieldTemplates() {
return _apiInvoke('getDefaultAnkiFieldTemplates');
}
+function apiGetAnkiDeckNames() {
+ return _apiInvoke('getAnkiDeckNames');
+}
+
+function apiGetAnkiModelNames() {
+ return _apiInvoke('getAnkiModelNames');
+}
+
+function apiGetAnkiModelFieldNames(modelName) {
+ return _apiInvoke('getAnkiModelFieldNames', {modelName});
+}
+
+function apiGetDictionaryInfo() {
+ return _apiInvoke('getDictionaryInfo');
+}
+
+function apiGetDictionaryCounts(dictionaryNames, getTotal) {
+ return _apiInvoke('getDictionaryCounts', {dictionaryNames, getTotal});
+}
+
+function apiPurgeDatabase() {
+ return _apiInvoke('purgeDatabase');
+}
+
function _apiInvoke(action, params={}) {
const data = {action, params};
return new Promise((resolve, reject) => {
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 2d11c11a..6a3298fc 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -316,6 +316,15 @@ const yomichan = (() => {
this.trigger('orphaned', {error});
}
+ isExtensionUrl(url) {
+ try {
+ const urlBase = chrome.runtime.getURL('/');
+ return url.substring(0, urlBase.length) === urlBase;
+ } catch (e) {
+ return false;
+ }
+ }
+
getTemporaryListenerResult(eventHandler, userCallback, timeout=null) {
if (!(
typeof eventHandler.addListener === 'function' &&
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js
index a1d96320..0cd12cd7 100644
--- a/ext/mixed/js/text-scanner.js
+++ b/ext/mixed/js/text-scanner.js
@@ -46,7 +46,7 @@ class TextScanner {
}
onMouseOver(e) {
- if (this.ignoreElements.includes(e.target)) {
+ if (this.ignoreElements().includes(e.target)) {
this.scanTimerClear();
}
}
@@ -133,7 +133,7 @@ class TextScanner {
this.preventNextClick = false;
const primaryTouch = e.changedTouches[0];
- if (DOM.isPointInSelection(primaryTouch.clientX, primaryTouch.clientY, this.node.getSelection())) {
+ if (DOM.isPointInSelection(primaryTouch.clientX, primaryTouch.clientY, window.getSelection())) {
return;
}
@@ -224,8 +224,8 @@ class TextScanner {
}
}
- setEnabled(enabled) {
- if (enabled) {
+ setEnabled(enabled, canEnable) {
+ if (enabled && canEnable) {
if (!this.enabled) {
this.hookEvents();
this.enabled = true;
@@ -271,9 +271,9 @@ class TextScanner {
];
}
- setOptions(options) {
+ setOptions(options, canEnable=true) {
this.options = options;
- this.setEnabled(this.options.general.enable);
+ this.setEnabled(this.options.general.enable, canEnable);
}
async searchAt(x, y, cause) {