From 0b15c878c7f722d8b67022813c5d7ec86cb541cb Mon Sep 17 00:00:00 2001 From: binaryDiv Date: Wed, 10 Oct 2018 01:22:14 +0200 Subject: [PATCH] Added button action menu --- main.js => content_scripts/fairlang.js | 0 manifest.json | 14 ++++++++------ popup/buttonmenu.html | 15 +++++++++++++++ popup/buttonmenu.js | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) rename main.js => content_scripts/fairlang.js (100%) create mode 100644 popup/buttonmenu.html create mode 100644 popup/buttonmenu.js diff --git a/main.js b/content_scripts/fairlang.js similarity index 100% rename from main.js rename to content_scripts/fairlang.js diff --git a/manifest.json b/manifest.json index 7a91b04..12b0785 100644 --- a/manifest.json +++ b/manifest.json @@ -8,10 +8,12 @@ "icons": { }, - "content_scripts": [ - { - "matches": ["http://*/*", "https://*/*", "file://*/*"], - "js": ["main.js"] - } - ] + "permissions": [ + "activeTab" + ], + + "browser_action": { + "default_title": "Fairlanguage", + "default_popup": "popup/buttonmenu.html" + } } diff --git a/popup/buttonmenu.html b/popup/buttonmenu.html new file mode 100644 index 0000000..c5808b9 --- /dev/null +++ b/popup/buttonmenu.html @@ -0,0 +1,15 @@ + + + + Test action + + + +

Fairlanguage

+

Meow meow.

+ + + + + + diff --git a/popup/buttonmenu.js b/popup/buttonmenu.js new file mode 100644 index 0000000..78a5dd8 --- /dev/null +++ b/popup/buttonmenu.js @@ -0,0 +1,15 @@ +// onclick handler for the "Activate on this page" button +function activateOnPage() { + // Inject content script into active tab + browser.tabs.executeScript({file: "/content_scripts/fairlang.js"}); + + // TODO exception handling +} + +// Add event handlers +document.addEventListener("click", (e) => { + if (e.target.id == "activateButton") { + activateOnPage(); + } +}); +