aboutsummaryrefslogtreecommitdiff
path: root/files/fr/mozilla/add-ons/webextensions/api/contentscripts/registeredcontentscript/unregister/index.html
blob: 4f52e84f245e1b0dcad70d6230898620c99ecef6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: contentScripts.RegisteredContentScript.unregister()
slug: >-
  Mozilla/Add-ons/WebExtensions/API/contentScripts/RegisteredContentScript/unregister
tags:
  - API
  - Extensions
  - Reference
  - RegisteredContentScript.unregister
  - contentScripts
translation_of: >-
  Mozilla/Add-ons/WebExtensions/API/contentScripts/RegisteredContentScript/unregister
---
<div>{{AddonSidebar()}}</div>

<div>Annule l'inscription des scripts de contenu représentés par cet objet <code>RegisteredContentScript</code>.</div>

<h2 id="Syntaxe">Syntaxe</h2>

<pre class="brush: js">registered.unregister()
</pre>

<h3 id="Paramètres">Paramètres</h3>

<p>None.</p>

<h3 id="Valeur_retournée">Valeur retournée</h3>

<p>None.</p>

<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2>

<p>{{Compat("webextensions.api.contentScripts.RegisteredContentScript.unregister", 10)}}</p>

<h2 id="Exemples">Exemples</h2>

<p>Ce code permet de basculer un script de contenu enregistré sur un clic d'action du navigateur :</p>

<pre class="brush: js">var registered = null;

async function register() {

  registered = await browser.contentScripts.register({
    matches: ["*://*.org/*"],
    js: [{
      code: "document.body.innerHTML = '&lt;h1&gt;This page has been eaten&lt;h1&gt;'"
    }],
    runAt: "document_idle"
  });

}

function toggle() {
  if (registered) {
    registered.unregister();
    registered = null;
  } else {
    register();
  }
}

browser.browserAction.onClicked.addListener(toggle);
</pre>

<p>{{WebExtExamples}}</p>