Added button action menu

This commit is contained in:
Lexi / Zoe 2018-10-10 01:22:14 +02:00
parent ac71dcc580
commit 0b15c878c7
4 changed files with 38 additions and 6 deletions

View File

@ -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"
}
]
}

15
popup/buttonmenu.html Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Test action</title>
</head>
<body>
<h1>Fairlanguage</h1>
<p>Meow meow.</p>
<button id="activateButton">Activate on this page</button>
<script src="buttonmenu.js"></script>
</body>
</html>

15
popup/buttonmenu.js Normal file
View File

@ -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();
}
});