Grammalecte  Diff

Differences From Artifact [342fbed920]:

To Artifact [16c99e6a6e]:


372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
var max = Math.floor(9999999);
function uniqueID() {
    return Date.now().toString(36) + "-" + (Math.floor(Math.random() * (max - min)) + min).toString(36);
}

// ! Ecoute des messages venant du scipt injecté
document.addEventListener("GrammalecteEvent", function(event) {
    let actionFromPage = event.detail;
    //console.log(event);
    let sText = false;
    let dInfo = {};
    let elmForGramma = null;

    if (actionFromPage.iframe) {
        elmForGramma = document.getElementById(actionFromPage.iframe).contentWindow.document.body;







|







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
var max = Math.floor(9999999);
function uniqueID() {
    return Date.now().toString(36) + "-" + (Math.floor(Math.random() * (max - min)) + min).toString(36);
}

// ! Ecoute des messages venant du scipt injecté
document.addEventListener("GrammalecteEvent", function(event) {
    let actionFromPage = JSON.parse(event.detail);
    //console.log(event);
    let sText = false;
    let dInfo = {};
    let elmForGramma = null;

    if (actionFromPage.iframe) {
        elmForGramma = document.getElementById(actionFromPage.iframe).contentWindow.document.body;
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
        dataToSend.elm = dataAction.elm.id;
    }

    if (!isLoaded) {
        bufferMsg.push(dataToSend);
    } else {
        //console.log('sendToWebpage', dataToSend);
        var eventGrammalecte = new CustomEvent("GrammalecteToPage", { detail: dataToSend });
        document.dispatchEvent(eventGrammalecte);
    }

    return dataToSend.IdAction;
}

// ! Les message ne peuvent être envoyer qu'après que le script est injecté
document.addEventListener("GrammalecteIsLoaded", function() {
    //console.log("GrammalecteIsLoaded EXT");
    isLoaded = true;
    if (bufferMsg.length > 0) {
        for (const dataToSend of bufferMsg) {
            var eventGrammalecte = new CustomEvent("GrammalecteToPage", { detail: dataToSend });
            document.dispatchEvent(eventGrammalecte);
        }
    }
});

sendToWebpage({ init: browser.extension.getURL("") });







|












|






425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
        dataToSend.elm = dataAction.elm.id;
    }

    if (!isLoaded) {
        bufferMsg.push(dataToSend);
    } else {
        //console.log('sendToWebpage', dataToSend);
        var eventGrammalecte = new CustomEvent("GrammalecteToPage", { detail: JSON.stringify(dataToSend) });
        document.dispatchEvent(eventGrammalecte);
    }

    return dataToSend.IdAction;
}

// ! Les message ne peuvent être envoyer qu'après que le script est injecté
document.addEventListener("GrammalecteIsLoaded", function() {
    //console.log("GrammalecteIsLoaded EXT");
    isLoaded = true;
    if (bufferMsg.length > 0) {
        for (const dataToSend of bufferMsg) {
            var eventGrammalecte = new CustomEvent("GrammalecteToPage", { detail: JSON.stringify(dataToSend) });
            document.dispatchEvent(eventGrammalecte);
        }
    }
});

sendToWebpage({ init: browser.extension.getURL("") });