2018-07-29 21:43:40 +02:00
|
|
|
/* 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";
|
|
|
|
|
2019-04-09 08:29:52 +02:00
|
|
|
const extension = require("../lib/extension");
|
2019-04-08 00:02:29 +02:00
|
|
|
const logging = require("../lib/logging");
|
|
|
|
const settings = require("../lib/settings");
|
2019-05-03 23:17:35 +02:00
|
|
|
require("../lib/theme").init();
|
2018-07-29 21:43:40 +02:00
|
|
|
logging.message("Opened browser action");
|
|
|
|
|
|
|
|
settings.onloaded(function(){
|
2019-11-28 01:26:35 +01:00
|
|
|
const actions = document.getElementById("actions");
|
2018-07-29 21:43:40 +02:00
|
|
|
|
|
|
|
[
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-03-22 16:33:22 +01:00
|
|
|
{
|
|
|
|
label: "faq",
|
|
|
|
icon: browser.extension.getURL("icons/browserAction-faq.svg"),
|
|
|
|
action: function(){
|
|
|
|
window.open("https://canvasblocker.kkapsner.de/faq/", "_blank");
|
|
|
|
}
|
|
|
|
},
|
2018-07-29 21:43:40 +02:00
|
|
|
{
|
|
|
|
label: "test",
|
|
|
|
advanced: true,
|
|
|
|
icon: browser.extension.getURL("icons/browserAction-test.svg"),
|
|
|
|
action: function(){
|
|
|
|
window.open("https://canvasblocker.kkapsner.de/test", "_blank");
|
|
|
|
}
|
|
|
|
},
|
2018-07-31 14:17:39 +02:00
|
|
|
{
|
|
|
|
label: "review",
|
|
|
|
icon: browser.extension.getURL("icons/browserAction-review.svg"),
|
|
|
|
action: function(){
|
2018-07-31 20:40:13 +02:00
|
|
|
window.open("https://addons.mozilla.org/firefox/addon/canvasblocker/reviews/", "_blank");
|
2018-07-31 14:17:39 +02:00
|
|
|
}
|
|
|
|
},
|
2018-07-29 21:43:40 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2019-11-28 01:26:35 +01:00
|
|
|
const actionButton = document.createElement("button");
|
2018-07-29 21:43:40 +02:00
|
|
|
actionButton.className = "action";
|
|
|
|
|
2019-11-28 01:26:35 +01:00
|
|
|
const icon = document.createElement("span");
|
2018-08-21 21:53:13 +02:00
|
|
|
icon.className = "icon";
|
|
|
|
icon.style.maskImage = "url(" + action.icon + ")";
|
2018-07-29 21:43:40 +02:00
|
|
|
|
|
|
|
actionButton.appendChild(icon);
|
|
|
|
|
|
|
|
actionButton.appendChild(
|
|
|
|
document.createTextNode(
|
2019-04-09 08:29:52 +02:00
|
|
|
extension.getTranslation("browserAction_" + action.label) || action.label
|
2018-07-29 21:43:40 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
actionButton.addEventListener("click", action.action);
|
|
|
|
actions.appendChild(actionButton);
|
|
|
|
});
|
2018-10-09 12:59:53 +02:00
|
|
|
|
2019-11-28 01:26:35 +01:00
|
|
|
const search = document.createElement("input");
|
2019-04-09 08:29:52 +02:00
|
|
|
search.placeholder = extension.getTranslation("search");
|
2018-10-09 12:59:53 +02:00
|
|
|
search.className = "search action";
|
|
|
|
actions.appendChild(search);
|
|
|
|
search.focus();
|
|
|
|
|
2018-10-09 20:44:13 +02:00
|
|
|
search.addEventListener("keypress", function(event){
|
2018-10-09 12:59:53 +02:00
|
|
|
if ([10, 13].indexOf(event.keyCode) !== -1){
|
|
|
|
window.open(browser.extension.getURL(
|
|
|
|
"options/options.html" +
|
|
|
|
"?search=" +
|
|
|
|
encodeURIComponent(this.value)
|
|
|
|
));
|
2018-10-09 20:44:13 +02:00
|
|
|
window.close();
|
2018-10-09 12:59:53 +02:00
|
|
|
}
|
|
|
|
});
|
2018-07-29 21:43:40 +02:00
|
|
|
});
|
|
|
|
}());
|