From c0210e10a76e20ab4ba5f8309052d75dde182d1a Mon Sep 17 00:00:00 2001 From: wareya Date: Sun, 16 Jun 2019 19:11:33 -0400 Subject: [PATCH] fix number bug --- dict/priority.json | 1 + texthook.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/dict/priority.json b/dict/priority.json index a6f7a2e..ae230aa 100644 --- a/dict/priority.json +++ b/dict/priority.json @@ -7,6 +7,7 @@ ["", "ず", 10000], ["", "や", 10000], + ["金", "かね", 20], ["額", "ひたい", 20], ["主", "あるじ", 20], ["前", "まえ", 20], diff --git a/texthook.js b/texthook.js index 3778748..9b49baf 100644 --- a/texthook.js +++ b/texthook.js @@ -1286,8 +1286,23 @@ browser.storage.onChanged.addListener((updates, storageArea) => let last_lookup = undefined; let last_manual_interaction = Date.now(); +function may_contain_japanese(text) +{ + for(let c of text.split("")) + if(c.codePointAt(0) > 0x3000) + return true; + return false; +} + +function is_number(c) +{ + return "1234567890".includes(c); +} + async function send_lookup(lookup) { + if(is_number(lookup[0].split("")[0]) && !may_contain_japanese(lookup[5])) + return; if(!settings.kanji_mode) { let response = await browser.runtime.sendMessage(