commit 6bd3e93c8c07523b6fa550bee7ffe00c669b0db7 Author: OverPoweredDev Date: Mon Aug 2 17:27:46 2021 +0530 changed tags to 's Just because tags are treated as inline tags now is no reason to assume it'll stay the same. Plus, the working barely changes diff --git a/src/lib/translate.js b/src/lib/translate.js index 180dac9..04faa5d 100644 --- a/src/lib/translate.js +++ b/src/lib/translate.js @@ -4,10 +4,10 @@ function addHoverTag(targetLanguage, sourceLanguage) { // - ([A-z0-9']+) apart from elements, we consider all words, numbers or words containing "'" $('p').each(function () { - $(this).html($(this).html().replace(/(?![^<]*?>)([A-z0-9']+)/g, '$1')); + $(this).html($(this).html().replace(/(?![^<]*?>)([A-z0-9']+)/g, '$1')); }); - $("hover").hover(async function () { + $("span").hover(async function () { let self = $(this) let preTranslation = self.attr('data-translation'); // basically just the data before translating it (possibly again) let original = self.attr('data-original'); @@ -24,9 +24,10 @@ function addHoverTag(targetLanguage, sourceLanguage) { // console.log(contextTranslation.innerText, parent.text()) // } - for (let element of parent.children()) { + for (let element of parent.children('[data-original]')) { let original = element.getAttribute('data-original'); let translation = contextTranslation.querySelector('[data-original="' + original + '"]'); + console.log(translation); translation.remove(); element.setAttribute('data-translation', translation.textContent);