1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Added browser toolbar icon

Fixes #217
This commit is contained in:
kkapsner 2018-07-29 21:43:40 +02:00
parent 9b18631768
commit 4a6c5192f8
9 changed files with 365 additions and 0 deletions

View file

@ -0,0 +1,43 @@
body {
padding: 1em;
}
div {
display: block;
}
.action {
display: block;
padding: 0.5em;
background-color: white;
border: 1px solid #e0e0e0;
cursor: pointer;
width: 100%;
text-align: left;
height: auto;
z-index: 1;
position: relative;
}
.action + .action {
border-top-width: 0;
}
.action:first-child {
border-radius: 3px 3px 0 0;
}
.action:last-child {
border-radius: 0 0 3px 3px;
}
.action:active, .action:hover, .action:focus {
z-index: 10;
background-color: #eaeaea;
}
.action img {
vertical-align: middle;
max-height: 19px;
margin-right: 0.25em;
}

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>CanvasBlocker browser action</title>
<link href="browserAction.css" rel="stylesheet" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="actions"></div>
<script src="../lib/require.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/logging.js"></script>
<script src="browserAction.js"></script>
</body>
</html>

View file

@ -0,0 +1,65 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){
"use strict";
const logging = require("./logging");
const settings = require("./settings");
logging.message("Opened browser action");
settings.onloaded(function(){
var actions = document.getElementById("actions");
[
{
label: "settings",
icon: browser.extension.getURL("icons/pageAction-showOptions.svg"),
action: function(){
if (browser.runtime && browser.runtime.openOptionsPage){
browser.runtime.openOptionsPage();
}
else {
window.open(browser.extension.getURL("options/options.html"), "_blank");
}
}
},
{
label: "test",
advanced: true,
icon: browser.extension.getURL("icons/browserAction-test.svg"),
action: function(){
window.open("https://canvasblocker.kkapsner.de/test", "_blank");
}
},
{
label: "reportIssue",
icon: browser.extension.getURL("icons/browserAction-reportIssue.svg"),
action: function(){
window.open("https://github.com/kkapsner/CanvasBlocker/issues", "_blank");
}
},
].forEach(function(action){
logging.verbose("Action", action);
if (action.advanced && !settings.displayAdvancedSettings){
logging.verbose("Hiding advanced action");
return;
}
var actionButton = document.createElement("button");
actionButton.className = "action";
var icon = document.createElement("img");
icon.src = action.icon;
actionButton.appendChild(icon);
actionButton.appendChild(
document.createTextNode(
browser.i18n.getMessage("browserAction_" + action.label) || action.label
)
);
actionButton.addEventListener("click", action.action);
actions.appendChild(actionButton);
});
});
}());