summaryrefslogtreecommitdiff
path: root/ext/fg/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/util.js')
-rw-r--r--ext/fg/js/util.js59
1 files changed, 14 insertions, 45 deletions
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index c38112f5..4fb8f288 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -119,6 +119,20 @@ function docImposterHide() {
}
function docRangeFromPoint(point, imposter) {
+ if (!document.elementFromPoint) {
+ document.elementFromPoint = (x, y) => {
+ const position = document.caretPositionFromPoint(x,y);
+ if (position === null) {
+ return null;
+ }
+
+ const range = document.createRange();
+ range.setStart(position.offsetNode, position.offset);
+ range.setEnd(position.offsetNode, position.offset);
+ return range;
+ };
+ }
+
const element = document.elementFromPoint(point.x, point.y);
if (element !== null) {
if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') {
@@ -195,51 +209,6 @@ function docSentenceExtract(source, extent) {
/*
- * Audio
- */
-
-function audioUrlBuild(definition) {
- let kana = definition.reading;
- let kanji = definition.expression;
-
- if (!kana && !kanji) {
- return null;
- }
-
- if (!kana && wanakana.isHiragana(kanji)) {
- kana = kanji;
- kanji = null;
- }
-
- const params = [];
- if (kanji) {
- params.push(`kanji=${encodeURIComponent(kanji)}`);
- }
- if (kana) {
- params.push(`kana=${encodeURIComponent(kana)}`);
- }
-
- return `https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?${params.join('&')}`;
-}
-
-function audioFilenameBuild(definition) {
- if (!definition.reading && !definition.expression) {
- return null;
- }
-
- let filename = 'yomichan';
- if (definition.reading) {
- filename += `_${definition.reading}`;
- }
- if (definition.expression) {
- filename += `_${definition.expression}`;
- }
-
- return filename += '.mp3';
-}
-
-
-/*
* Error
*/