From 34d315396ca29d7ef51ecc27eeeeeb275e9b0ba9 Mon Sep 17 00:00:00 2001 From: SphinxKnight Date: Mon, 15 Nov 2021 19:39:07 +0100 Subject: 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 --- .../webextensions/api/runtime/port/index.html | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html') diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html index 6f3864f5aa..0d5f60172d 100644 --- a/files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html @@ -31,7 +31,7 @@ translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/Port

Vous devez utiliser différentes API de connexion pour différents types de connexions, comme indiqué dans le tableau ci-dessous.

- +
@@ -67,7 +67,7 @@ translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/Port

Les valeurs de ce type sont des objets. Ils contiennent les propriétés suivantes :

-
+
name
string. Le nom du port, défini dans {{WebExtAPIRef("runtime.connect()")}} ou {{WebExtAPIRef("tabs.connect()")}} appel qui l'a créé. Si ce port est connecté à une application native, son nom est le nom de l'application native.
disconnect
@@ -110,19 +110,19 @@ translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/Port
  • sends messages to the background script, using myPort, when the user clicks the document.
  • -
    // content-script.js
    +
    // content-script.js
     
    -var myPort = browser.runtime.connect({name:"port-from-cs"});
    -myPort.postMessage({greeting: "hello from content script"});
    +var myPort = browser.runtime.connect({name:"port-from-cs"});
    +myPort.postMessage({greeting: "hello from content script"});
     
    -myPort.onMessage.addListener(function(m) {
    -  console.log("In content script, received message from background script: ");
    -  console.log(m.greeting);
    -});
    +myPort.onMessage.addListener(function(m) {
    +  console.log("In content script, received message from background script: ");
    +  console.log(m.greeting);
    +});
     
    -document.body.addEventListener("click", function() {
    -  myPort.postMessage({greeting: "they clicked the page!"});
    -});
    +document.body.addEventListener("click", function() { + myPort.postMessage({greeting: "they clicked the page!"}); +});

    The corresponding background script:

    @@ -138,24 +138,24 @@ document.body// background-script.js +
    // background-script.js
     
    -var portFromCS;
    +var portFromCS;
     
    -function connected(p) {
    -  portFromCS = p;
    -  portFromCS.postMessage({greeting: "hi there content script!"});
    -  portFromCS.onMessage.addListener(function(m) {
    -    console.log("In background script, received message from content script")
    -    console.log(m.greeting);
    -  });
    -}
    +function connected(p) {
    +  portFromCS = p;
    +  portFromCS.postMessage({greeting: "hi there content script!"});
    +  portFromCS.onMessage.addListener(function(m) {
    +    console.log("In background script, received message from content script")
    +    console.log(m.greeting);
    +  });
    +}
     
    -browser.runtime.onConnect.addListener(connected);
    +browser.runtime.onConnect.addListener(connected);
     
    -browser.browserAction.onClicked.addListener(function() {
    -  portFromCS.postMessage({greeting: "they clicked the button!"});
    -});
    +browser.browserAction.onClicked.addListener(function() { + portFromCS.postMessage({greeting: "they clicked the button!"}); +});

    Script à contenu multiple

    @@ -207,7 +207,7 @@ browser.browserAction.onClicked.addListener(() => {

    {{WebExtExamples}}

    -
    Remerciements : +

    Note :

    Cette API est basée sur l'API Chromium chrome.runtime. Cette documentation est dérivée de runtime.json dans le code de Chromium code.

    -- cgit v1.2.3-54-g00ecf
    type de connection