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 @@ -137,16 +137,16 @@ this.createMenus(); }, createTFPanel: function () { if (this.oTFPanel === null) { - this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 760, 600, false); + this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 760, 615, false); //this.oTFPanel.logInnerHTML(); this.oTFPanel.insertIntoPage(); window.setTimeout(function(self){ self.oTFPanel.adjustHeight(); - }, 1, this); + }, 50, this); } }, createLxgPanel: function () { if (this.oLxgPanel === null) { @@ -230,10 +230,14 @@ let {sActionDone, result, dInfo, bEnd, bError} = oMessage; let sText = ""; switch (sActionDone) { case "init": oGrammalecte.sExtensionUrl = oMessage.sUrl; + // Start + oGrammalecte.listenRightClick(); + oGrammalecte.createMenus(); + oGrammalecte.observePage(); break; case "parseAndSpellcheck": if (!bEnd) { oGrammalecte.oGCPanel.addParagraphResult(result); } else { @@ -327,13 +331,5 @@ break; default: console.log("[Content script] Unknown command: " + sActionDone); } }); - - -/* - Start -*/ -oGrammalecte.listenRightClick(); -oGrammalecte.createMenus(); -oGrammalecte.observePage(); Index: gc_lang/fr/webext/content_scripts/menu.css ================================================================== --- gc_lang/fr/webext/content_scripts/menu.css +++ gc_lang/fr/webext/content_scripts/menu.css @@ -46,15 +46,10 @@ /* Menu */ -div.grammalecte_abs { - display: none; - position: absolute; -} - div.grammalecte_menu { all: initial; display: none; position: absolute; margin-left: -10px; Index: gc_lang/fr/webext/content_scripts/menu.js ================================================================== --- gc_lang/fr/webext/content_scripts/menu.js +++ gc_lang/fr/webext/content_scripts/menu.js @@ -10,41 +10,47 @@ class GrammalecteMenu { constructor (nMenu, xNode) { this.xNode = xNode; this.sMenuId = "grammalecte_menu" + nMenu; - this.bShadow = document.body.createShadowRoot || document.body.attachShadow; this.xButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_main_button", textContent: " "}); this.xButton.onclick = () => { this.switchMenu(); }; this.xButton.style.zIndex = (xNode.style.zIndex.search(/^[0-9]+$/) !== -1) ? (parseInt(xNode.style.zIndex) + 1).toString() : xNode.style.zIndex; this.xMenu = this._createMenu(); let xStyle = window.getComputedStyle(this.xNode); - let nMarginTop = -1 * (8 + parseInt(xStyle.marginBottom.replace('px', ''), 10)); let xNodeInsertAfter = this.xNode; if (document.location.host == "twitter.com" && this.xNode.classList.contains('rich-editor')) { xNodeInsertAfter = this.xNode.parentNode; } + this.bShadow = document.body.createShadowRoot || document.body.attachShadow; if (this.bShadow){ - this.oShadowBtn = oGrammalecte.createNode("div", {className: "grammalecte_abs", style: "width:16px;height:16px;"}); + let nMarginTop = -1 * (parseInt(xStyle.marginBottom.replace('px', ''), 10)); + this.oShadowBtn = oGrammalecte.createNode("div", {style: "display:none;position:absolute;width:0;height:0;"}); this.oShadowBtnNode = this.oShadowBtn.attachShadow({mode: "open"}); this.oShadowBtnNode.appendChild( oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"}) ); this.oShadowBtnNode.appendChild(this.xButton); this._insertAfter(this.oShadowBtn, xNodeInsertAfter, nMarginTop); - this.oShadowMenu = oGrammalecte.createNode("div", {id: this.sMenuId+"_shadow", className: "grammalecte_abs", style: "width:0;height:0;"}); + this.oShadowMenu = oGrammalecte.createNode("div", {id: this.sMenuId+"_shadow", style: "display:none;position:absolute;width:0;height:0;"}); this.oShadowMenuNode = this.oShadowMenu.attachShadow({mode: "open"}); this.oShadowMenuNode.appendChild( oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"}) ); this.oShadowMenuNode.appendChild(this.xMenu); this._insertAfter(this.oShadowMenu, xNodeInsertAfter, nMarginTop + 8); } else { + let nMarginTop = -1 * (8 + parseInt(xStyle.marginBottom.replace('px', ''), 10)); + if (!document.getElementById("grammalecte_cssmenu")){ + document.head.appendChild( + oGrammalecte.createNode("link", {id: "grammalecte_cssmenu", rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"}) + ); + } this._insertAfter(this.xButton, xNodeInsertAfter, nMarginTop); this._insertAfter(this.xMenu, xNodeInsertAfter, nMarginTop + 8); } this._createListeners(); } Index: gc_lang/fr/webext/content_scripts/message_box.js ================================================================== --- gc_lang/fr/webext/content_scripts/message_box.js +++ gc_lang/fr/webext/content_scripts/message_box.js @@ -72,10 +72,18 @@ oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/message_box.css"}) ); this.oShadow.appendChild(this.xMessageBox); document.body.appendChild(this.oShadowPanel); } else { + if (!document.getElementById("grammalecte_cssmsg")){ + document.head.appendChild( + oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel.css"}) + ); + document.head.appendChild( + oGrammalecte.createNode("link", {id: "grammalecte_cssmsg", rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/message_box.css"}) + ); + } document.body.appendChild(this.xMessageBox); } } show () { Index: gc_lang/fr/webext/content_scripts/panel.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel.js +++ gc_lang/fr/webext/content_scripts/panel.js @@ -111,10 +111,24 @@ oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_tf.css"}) ); this.oShadow.appendChild(this.xPanel); document.body.appendChild(this.oShadowPanel); } else { + if (!document.getElementById("grammalecte_csspanel")){ + document.head.appendChild( + oGrammalecte.createNode("link", {id: "grammalecte_csspanel", rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel.css"}) + ); + document.head.appendChild( + oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_gc.css"}) + ); + document.head.appendChild( + oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_lxg.css"}) + ); + document.head.appendChild( + oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_tf.css"}) + ); + } document.body.appendChild(this.xPanel); } } show () { Index: gc_lang/fr/webext/content_scripts/panel_tf.css ================================================================== --- gc_lang/fr/webext/content_scripts/panel_tf.css +++ gc_lang/fr/webext/content_scripts/panel_tf.css @@ -111,10 +111,11 @@ div#grammalecte_tf_reset:hover { background-color: hsl(210, 50%, 40%); } progress#grammalecte_tf_progressbar { width: 360px; + height: 29px; } span#grammalecte_tf_time_res { width: 60px; padding: 5px 10px; } Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -46,18 +46,10 @@ "exclude_matches": [ "*://*.wikisource.org/*", "*://*.wikipedia.org/*", "*://*.wiktionary.org/*" ], - "css": [ - "content_scripts/panel.css", - "content_scripts/panel_tf.css", - "content_scripts/panel_gc.css", - "content_scripts/panel_lxg.css", - "content_scripts/message_box.css", - "content_scripts/menu.css" - ], "js": [ "content_scripts/panel.js", "grammalecte/fr/textformatter.js", "content_scripts/panel_tf.js", "content_scripts/panel_gc.js", @@ -72,17 +64,10 @@ "matches": [ "*://*.wikisource.org/*", "*://*.wikipedia.org/*", "*://*.wiktionary.org/*" ], - "css": [ - "content_scripts/panel.css", - "content_scripts/panel_tf.css", - "content_scripts/panel_gc.css", - "content_scripts/panel_lxg.css", - "content_scripts/menu.css" - ], "js": [ "content_scripts/panel.js", "grammalecte/fr/textformatter.js", "content_scripts/panel_tf.js", "content_scripts/panel_gc.js",