Index: gc_lang/fr/webext/content_scripts/init.js ================================================================== --- gc_lang/fr/webext/content_scripts/init.js +++ gc_lang/fr/webext/content_scripts/init.js @@ -363,32 +363,36 @@ scriptEvent.src = browser.extension.getURL("content_scripts/event.js"); document.documentElement.appendChild(scriptEvent); document.addEventListener('GrammalecteEvent', function(event) { let actionFromPage = event.detail; - console.log(event); - let sText = false; - let dInfo = {}; - let elmForGramma = null; - if (actionFromPage.elm){ - elmForGramma = document.getElementById(actionFromPage.elm); - sText = (elmForGramma.tagName == "TEXTAREA") ? elmForGramma.value : elmForGramma.innerText; - dInfo = {sTextAreaId: elmForGramma.id}; - } - - if (actionFromPage.spellcheck){ - oGrammalecte.startGCPanel(elmForGramma); - xGrammalectePort.postMessage({ - sCommand: "parseAndSpellcheck", - dParam: {sText: sText || actionFromPage.parseAndSpellcheck, sCountry: "FR", bDebug: false, bContext: false}, - dInfo: dInfo - }); - } - if (actionFromPage.lexique){ - oGrammalecte.startLxgPanel(); - xGrammalectePort.postMessage({ - sCommand: "getListOfTokens", - dParam: {sText: sText || actionFromPage.lexique}, - dInfo: dInfo - }); + //console.log(event); + if(actionFromPage){ + let sText = false; + let dInfo = {}; + let elmForGramma = null; + if (actionFromPage.elm){ + elmForGramma = document.getElementById(actionFromPage.elm); + sText = (elmForGramma.tagName == "TEXTAREA") ? elmForGramma.value : elmForGramma.innerText; + dInfo = {sTextAreaId: elmForGramma.id}; + } + + if (actionFromPage.spellcheck){ + oGrammalecte.startGCPanel(elmForGramma); + xGrammalectePort.postMessage({ + sCommand: "parseAndSpellcheck", + dParam: {sText: sText || actionFromPage.parseAndSpellcheck, sCountry: "FR", bDebug: false, bContext: false}, + dInfo: dInfo + }); + } + if (actionFromPage.lexique){ + oGrammalecte.startLxgPanel(); + xGrammalectePort.postMessage({ + sCommand: "getListOfTokens", + dParam: {sText: sText || actionFromPage.lexique}, + dInfo: dInfo + }); + } + } else { + console.log("Vous devez spécifier l'action à effectuer"); } });