diff --git a/background-script.js b/background-script.js index a7476f2..17de313 100644 --- a/background-script.js +++ b/background-script.js @@ -14,7 +14,8 @@ let lookup_epwing_kana = new Map(); async function refresh_epwing() { - epwing = (await browser.storage.local.get("epwing"))["epwing"]; + let myjson = (await browser.storage.local.get("epwing"))["epwing"]; + epwing = JSON.parse(myjson); lookup_epwing_kan = new Map(); lookup_epwing_kana = new Map(); for (let i = 1; i < epwing.length; i++) diff --git a/background.html b/background.html index 4f87819..e88b0b8 100644 --- a/background.html +++ b/background.html @@ -1 +1,7 @@ - + + + + + + + diff --git a/options.js b/options.js index 5ae1e11..4bb1704 100644 --- a/options.js +++ b/options.js @@ -292,22 +292,21 @@ function buildpage() file.addEventListener("change", () => { let fname = document.querySelector("#file").files[0]; - let fr = new FileReader(); - fr.onload = (e) => + let reader = new FileReader(); + reader.onload = async(e) => { try { - document.querySelector("#import_label").textContent = "Importing..."; - browser.storage.local.set({"epwing":JSON.parse(e.target.result)}); + browser.storage.local.set({"epwing":JSON.stringify(JSON.parse(e.target.result))}); browser.runtime.sendMessage({type:"refreshepwing"}); document.querySelector("#import_label").textContent = "Imported. Might take a few seconds to apply."; } - catch(e) + catch(except) { - console.log(e); + console.log(except.stack); } }; - fr.readAsText(fname); + reader.readAsText(fname); }); let label = document.createElement("label"); label.for = file.id; diff --git a/texthook.js b/texthook.js index 687ce6a..6e66625 100644 --- a/texthook.js +++ b/texthook.js @@ -188,7 +188,7 @@ function display_div (middle, x, y, time) outer.style.bottom = (newy+settings.yoffset)+"px"; outer.style.right = "unset"; outer.style.left = (newx+settings.xoffset)+"px"; - outer.style.marginRight = "-10000000000000000px"; // fixes an absolute positioning """feature""" on very wide pages (e.g. pages of vertical text) + outer.style.marginRight = "-10000000000000000px"; // fixes an absolute positioning """feature""" that doesn't work properly with very wide pages (e.g. pages of vertical text) outer.style.marginLeft = "unset"; } else if(corner == 1) @@ -206,7 +206,7 @@ function display_div (middle, x, y, time) outer.style.bottom = "unset"; outer.style.right = "unset"; outer.style.left = (newx+settings.xoffset)+"px"; - outer.style.marginRight = "-10000000000000000px"; // fixes an absolute positioning """feature""" on very wide pages (e.g. pages of vertical text) + outer.style.marginRight = "-10000000000000000px"; // fixes an absolute positioning """feature""" that doesn't work properly with very wide pages (e.g. pages of vertical text) outer.style.marginLeft = "unset"; } } @@ -316,8 +316,7 @@ function build_div_inner (text, result) keb.textContent = kanji_text; temptag.appendChild(keb); - // list readings - let readings = term.r_ele; + // deconjugations if(term.deconj) { @@ -367,6 +366,10 @@ function build_div_inner (text, result) } temptag.appendChild(maininfos); } + + // list readings + let readings = term.r_ele; + temptag.appendChild(document.createTextNode(" 《")); let e_readings = document.createElement("span"); e_readings.className = "nazeka_readings"; @@ -935,6 +938,7 @@ function update(event) try { let display = getComputedStyle(current_node).display; + // break out of elements neither inline nor ruby if(display != "inline" && display != "ruby") break; } catch(err) {} @@ -955,10 +959,30 @@ function update(event) try { let display = getComputedStyle(next_node).display; - if(display == "ruby") + if(display == "ruby-text") continue; + if(display == "inline") text += next_node.textContent; + // BUG: this should technically be recursive, not a special case, but it won't affect any real webpages + if(display == "ruby") + { + for(let child of next_node.childNodes) + { + try + { + let display = getComputedStyle(child).display; + if(display == "ruby-text") + continue; + if(display == "inline") + text += child.textContent; + } + catch(err) + { + text += child.textContent; + } + } + } } catch(err) {