Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

Learn More

I want to write an addon firewall but it fails

more options
#!/bin/bash

# Verzeichnis erstellen
mkdir FoxyAddOnFirewall
cd FoxyAddOnFirewall || exit

# package.json erstellen
cat <<EOF > package.json
{
  "title": "Foxy AddOn Firewall",
  "name": "foxy-addon-firewall",
  "description": "A Firefox addon to control internet access for other addons",
  "author": "Your Name",
  "version": "1.0.0",
  "license": "MIT"
}
EOF

# background.js erstellen
cat <<EOF > background.js
var permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
                        .getService(Components.interfaces.nsIPermissionManager);

// Addon-Liste abrufen
function getAllAddons() {
    var {AddonManager} = Components.utils.import("resource://gre/modules/AddonManager.jsm", {});
    return new Promise(function(resolve, reject) {
        AddonManager.getAllAddons(function(addons) {
            resolve(addons);
        });
    });
}

// GUI aktualisieren
function updateUI() {
    getAllAddons().then(function(addons) {
        var addonList = document.getElementById("addon-list");
        addonList.innerHTML = ""; // Zurücksetzen der Liste

        addons.forEach(function(addon) {
            var listItem = document.createElement("li");
            listItem.textContent = addon.name;
            
            var blockButton = document.createElement("button");
            blockButton.textContent = "Block";
            blockButton.addEventListener("click", function() {
                blockInternetAccessForAddon(addon);
            });

            listItem.appendChild(blockButton);
            addonList.appendChild(listItem);
        });
    });
}

// Internetzugriff für ein bestimmtes Addon blockieren
function blockInternetAccessForAddon(addon) {
    var host = addon.getResourceURI("").host;
    permissionManager.remove(host, "allAccess");
    console.log("Internetzugriff für " + addon.name + " wurde blockiert.");
}

document.addEventListener("DOMContentLoaded", function() {
    updateUI(); // GUI beim Laden der Seite aktualisieren
});
EOF

# index.html erstellen
cat <<EOF > index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Foxy AddOn Firewall</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>Foxy AddOn Firewall</h1>
  <p>Welcome to Foxy AddOn Firewall!</p>

  <h2>Installed Addons:</h2>
  <ul id="addon-list">
    <!-- Addon-Liste wird hier eingefügt -->
  </ul>

  <script src="background.js"></script>
</body>
</html>
EOF

# style.css erstellen
cat <<EOF > style.css
body {
  font-family: Arial, sans-serif;
  background-color: #f0f0f0;
  text-align: center;
}

h1 {
  color: #007bff;
}

h2 {
  margin-top: 20px;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  margin-bottom: 10px;
}

button {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}
EOF

# manifest.json erstellen
cat <<EOF > manifest.json
{
  "manifest_version": 2,
  "name": "Foxy AddOn Firewall",
  "version": "1.0",
  "description": "A Firefox addon to control internet access for other addons",
  "icons": {
    "48": "icon.png"
  },
  "permissions": [
    "management"
  ],
  "browser_action": {
    "default_popup": "index.html",
    "default_icon": "icon.png"
  }
}
EOF

# Icon herunterladen
wget -O icon.png "https://img.icons8.com/ios-filled/50/000000/firewall.png"

# Installationsanweisungen anzeigen
echo "FoxyAddOnFirewall wurde erfolgreich initialisiert!"
echo "Um das Addon in Firefox zu installieren:"
echo "1. Öffnen Sie Firefox und geben Sie 'about:debugging' in die Adressleiste ein."
echo "2. Klicken Sie auf 'Dieses Firefox installieren' unter 'Temporäre Add-ons laden'."
echo "3. Navigieren Sie zum Verzeichnis 'FoxyAddOnFirewall' und wählen Sie die 'manifest.json' Datei aus."
echo "4. Das Addon wird nun installiert und kann verwendet werden."
<pre><nowiki>#!/bin/bash # Verzeichnis erstellen mkdir FoxyAddOnFirewall cd FoxyAddOnFirewall || exit # package.json erstellen cat <<EOF > package.json { "title": "Foxy AddOn Firewall", "name": "foxy-addon-firewall", "description": "A Firefox addon to control internet access for other addons", "author": "Your Name", "version": "1.0.0", "license": "MIT" } EOF # background.js erstellen cat <<EOF > background.js var permissionManager = Components.classes["@mozilla.org/permissionmanager;1"] .getService(Components.interfaces.nsIPermissionManager); // Addon-Liste abrufen function getAllAddons() { var {AddonManager} = Components.utils.import("resource://gre/modules/AddonManager.jsm", {}); return new Promise(function(resolve, reject) { AddonManager.getAllAddons(function(addons) { resolve(addons); }); }); } // GUI aktualisieren function updateUI() { getAllAddons().then(function(addons) { var addonList = document.getElementById("addon-list"); addonList.innerHTML = ""; // Zurücksetzen der Liste addons.forEach(function(addon) { var listItem = document.createElement("li"); listItem.textContent = addon.name; var blockButton = document.createElement("button"); blockButton.textContent = "Block"; blockButton.addEventListener("click", function() { blockInternetAccessForAddon(addon); }); listItem.appendChild(blockButton); addonList.appendChild(listItem); }); }); } // Internetzugriff für ein bestimmtes Addon blockieren function blockInternetAccessForAddon(addon) { var host = addon.getResourceURI("").host; permissionManager.remove(host, "allAccess"); console.log("Internetzugriff für " + addon.name + " wurde blockiert."); } document.addEventListener("DOMContentLoaded", function() { updateUI(); // GUI beim Laden der Seite aktualisieren }); EOF # index.html erstellen cat <<EOF > index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Foxy AddOn Firewall</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Foxy AddOn Firewall</h1> <p>Welcome to Foxy AddOn Firewall!</p> <h2>Installed Addons:</h2> <ul id="addon-list"> <!-- Addon-Liste wird hier eingefügt --> </ul> <script src="background.js"></script> </body> </html> EOF # style.css erstellen cat <<EOF > style.css body { font-family: Arial, sans-serif; background-color: #f0f0f0; text-align: center; } h1 { color: #007bff; } h2 { margin-top: 20px; } ul { list-style-type: none; padding: 0; } li { margin-bottom: 10px; } button { background-color: #007bff; color: white; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; } button:hover { background-color: #0056b3; } EOF # manifest.json erstellen cat <<EOF > manifest.json { "manifest_version": 2, "name": "Foxy AddOn Firewall", "version": "1.0", "description": "A Firefox addon to control internet access for other addons", "icons": { "48": "icon.png" }, "permissions": [ "management" ], "browser_action": { "default_popup": "index.html", "default_icon": "icon.png" } } EOF # Icon herunterladen wget -O icon.png "https://img.icons8.com/ios-filled/50/000000/firewall.png" # Installationsanweisungen anzeigen echo "FoxyAddOnFirewall wurde erfolgreich initialisiert!" echo "Um das Addon in Firefox zu installieren:" echo "1. Öffnen Sie Firefox und geben Sie 'about:debugging' in die Adressleiste ein." echo "2. Klicken Sie auf 'Dieses Firefox installieren' unter 'Temporäre Add-ons laden'." echo "3. Navigieren Sie zum Verzeichnis 'FoxyAddOnFirewall' und wählen Sie die 'manifest.json' Datei aus." echo "4. Das Addon wird nun installiert und kann verwendet werden."</nowiki></pre>

글쓴이 cor-el 수정일시

모든 댓글 (1)

more options

Hi, this forum focuses on end user questions. Could you try the Add-on Development forum here:

https://discourse.mozilla.org/c/add-ons/development/108

도움이 되셨습니까?

질문하기

글에 답글을 달기 위해서는 계정으로 로그인해야만 합니다. 계정이 아직 없다면 새로운 질문을 올려주세요.