Added button action menu
This commit is contained in:
parent
ac71dcc580
commit
0b15c878c7
|
|
@ -8,10 +8,12 @@
|
||||||
"icons": {
|
"icons": {
|
||||||
},
|
},
|
||||||
|
|
||||||
"content_scripts": [
|
"permissions": [
|
||||||
{
|
"activeTab"
|
||||||
"matches": ["http://*/*", "https://*/*", "file://*/*"],
|
],
|
||||||
"js": ["main.js"]
|
|
||||||
}
|
"browser_action": {
|
||||||
]
|
"default_title": "Fairlanguage",
|
||||||
|
"default_popup": "popup/buttonmenu.html"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Loading…
Reference in New Issue