diff options
author | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-11-15 19:39:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-15 19:39:07 +0100 |
commit | 34d315396ca29d7ef51ecc27eeeeeb275e9b0ba9 (patch) | |
tree | 21f671201b06ff6b0e507de867950b71fe1fddaf /files/fr/mozilla/add-ons/webextensions/api/menus/refresh/index.html | |
parent | 3886d96643d8b7cc626f1dda0e11981ac85def86 (diff) | |
download | translated-content-34d315396ca29d7ef51ecc27eeeeeb275e9b0ba9.tar.gz translated-content-34d315396ca29d7ef51ecc27eeeeeb275e9b0ba9.tar.bz2 translated-content-34d315396ca29d7ef51ecc27eeeeeb275e9b0ba9.zip |
Prepare Mozilla section for Markdown conversion (#2980)
* Remove summary
* Remove hidden except for copyright notice
* Remove spans
* Remove font
* Remove notranslate
* Remove extra id, deleting an untranslated page doing so
* Fix links, absolute links, rm internal, titles
* Remove external classes
* fix headings with name attr
* fix some styles and classes
* remove useless class reference-values
* rm styles in links
* Fix code blocks in pre
* Remove ltr classes
* remove fullwidth-table
* Fix various conversion errors and some one offs
* Remove nested code/pre/code
* Fix notes
* Fix warnings
* fix dls
* fix nested issues in dls
* fix images
Diffstat (limited to 'files/fr/mozilla/add-ons/webextensions/api/menus/refresh/index.html')
-rw-r--r-- | files/fr/mozilla/add-ons/webextensions/api/menus/refresh/index.html | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/files/fr/mozilla/add-ons/webextensions/api/menus/refresh/index.html b/files/fr/mozilla/add-ons/webextensions/api/menus/refresh/index.html index b0b332523c..925305277d 100644 --- a/files/fr/mozilla/add-ons/webextensions/api/menus/refresh/index.html +++ b/files/fr/mozilla/add-ons/webextensions/api/menus/refresh/index.html @@ -26,7 +26,7 @@ translation_of: Mozilla/Add-ons/WebExtensions/API/menus/refresh <h2 id="Syntaxe">Syntaxe</h2> -<pre class="syntaxbox brush:js">browser.menus.refresh() +<pre class="brush: js">browser.menus.refresh() </pre> <h3 id="Paramètres">Paramètres</h3> @@ -45,20 +45,20 @@ translation_of: Mozilla/Add-ons/WebExtensions/API/menus/refresh <p>Cet exemple permet d'afficher le menu contextuel sur un lien, puis met à jour l'élément de menu <code>openLabelledId</code> menu item avec le nom d'hôte du lien :</p> -<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">updateMenuItem</span><span class="punctuation token">(</span>linkHostname<span class="punctuation token">)</span> <span class="punctuation token">{</span> - browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">update</span><span class="punctuation token">(</span>openLabelledId<span class="punctuation token">,</span> <span class="punctuation token">{</span> - title<span class="punctuation token">:</span> <span class="template-string token"><span class="string token">`Open (</span><span class="interpolation token"><span class="interpolation-punctuation punctuation token">${</span>linkHostname<span class="interpolation-punctuation punctuation token">}</span></span><span class="string token">)`</span></span> - <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span><span class="function token">refresh</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span> - -browser<span class="punctuation token">.</span>menus<span class="punctuation token">.</span>onShown<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>info <span class="operator token">=</span><span class="operator token">></span> <span class="punctuation token">{</span> - <span class="keyword token">if</span> <span class="punctuation token">(</span><span class="operator token">!</span>info<span class="punctuation token">.</span>linkUrl<span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="keyword token">return</span><span class="punctuation token">;</span> - <span class="punctuation token">}</span> - <span class="keyword token">let</span> linkElement <span class="operator token">=</span> document<span class="punctuation token">.</span><span class="function token">createElement</span><span class="punctuation token">(</span><span class="string token">"a"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - linkElement<span class="punctuation token">.</span>href <span class="operator token">=</span> info<span class="punctuation token">.</span>linkUrl<span class="punctuation token">;</span> - <span class="function token">updateMenuItem</span><span class="punctuation token">(</span>linkElement<span class="punctuation token">.</span>hostname<span class="punctuation token">)</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> +<pre class="brush: js">function updateMenuItem(linkHostname) { + browser.menus.update(openLabelledId, { + title: `Open (${linkHostname})` + }); + browser.menus.refresh(); +} + +browser.menus.onShown.addListener(info => { + if (!info.linkUrl) { + return; + } + let linkElement = document.createElement("a"); + linkElement.href = info.linkUrl; + updateMenuItem(linkElement.hostname); +});</pre> <p>{{WebExtExamples}}</p> |