add dashboard.xpi for directplugin installation

main
viehlieb 2022-03-16 11:49:33 +01:00
parent 07f663abb0
commit 3ea78260b6
5 changed files with 46 additions and 28 deletions

View File

@ -1,5 +1,8 @@
"use strict";
//Simple background script that seds a message to content script
// code mainly from: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage
function onError(error) {
console.error(`Error: ${error}`);
}
@ -8,7 +11,7 @@ function sendMessageToTabs(tabs) {
for (let tab of tabs) {
browser.tabs.sendMessage(
tab.id,
{overlay: "display"}
{trigger: "extension click"}
).then(response => {
}).catch(onError);
}

Binary file not shown.

View File

@ -1,26 +1,29 @@
var buttonsize = 250;
var baseUrl="";
var buttonOffset = 250; //determines where the first of three buttons is rendered
var baseUrl="default"; //shortcuts should only work when baseUrl is included in current url
document.addEventListener("keyup", (event) => {
if (event.ctrlKey && event.code == "Enter") {
if(document.location.host.includes(baseUrl))
{
doStuff();
toggleDisplayBoard();
}
}
});
function doStuff()
// displays the board as overlay
function toggleDisplayBoard()
{
var dashboard = document.querySelector('#lit-dashboard');
isFront = dashboard.style.display === 'block';
viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
viewportHeight = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
console.log(viewportWidth + 'px');
dashboard.style.left = (document.documentElement.clientWidth/2) - 1.5*buttonsize + 'px' ;
dashboard.style.top = (viewportHeight/2) - buttonsize + 'px';
dashboard.style.left = (document.documentElement.clientWidth/2) - 1.5*buttonOffset + 'px' ;
dashboard.style.top = (viewportHeight/2) - buttonOffset + 'px';
dashboard.style.position = "fixed";
dashboard.style.zIndex = "3000";
dashboard.style.display = isFront ? 'none' : 'block';
}
@ -28,49 +31,57 @@ function onError(error) {
console.log(`Error: ${error}`);
}
// gets rid of all the Buttons
function deleteButtons(dashboard)
{
document.getElementById("dashboard-nextcloud-button").remove();
document.getElementById("dashboard-wekan-button").remove();
document.getElementById("dashboard-authentik-button").remove();
}
// adds the Buttons and the link prefixes
// button.click() leads to prefix + baseUrl
function createButtons(baseUrl, dashboard)
{
links= {dashboard: "https://", wekan: "https://board.", nextcloud: "https://cloud." }
// Button to Wekan at links["wekan"]+baseUrl
var wekanButton = document.createElement("button");
//wekanButton.innerHTML = "Wekan";
wekanButton.style.position= "relative";
wekanButton.style.top= buttonsize + 'px';
wekanButton.style.top= buttonOffset + 'px';
wekanButton.setAttribute("class", "lit-button wekan-button");
wekanButton.setAttribute("id", "dashboard-wekan-button");
wekanButton.addEventListener ("click", function() {
window.open(links["wekan"] + baseUrl, "_self");
});
// Button to authentik at links["dashboard"]+baseUrl
var authentikButton = document.createElement("button");
//authentikButton.innerHTML = "Dashboard";
authentikButton.setAttribute("class", "lit-button authentik-button");
authentikButton.setAttribute("id", "dashboard-authentik-button");
authentikButton.addEventListener ("click", function() {
window.open(links["dashboard"] + baseUrl, "_self");
});
// Button to nextcloud at links["nextcloud"]+baseUrl
var nextcloudButton = document.createElement("button");
//nextcloudButton.innerHTML = "Nextcloud";
nextcloudButton.setAttribute("class", "lit-button nextcloud-button");
nextcloudButton.setAttribute("id", "dashboard-nextcloud-button");
nextcloudButton.addEventListener ("click", function() {
window.open(links["nextcloud"] + baseUrl, "_self");
});
// 2. Append somewhere
// Append buttons to "lit-dashboard"
dashboard.appendChild(nextcloudButton);
dashboard.appendChild(wekanButton);
dashboard.appendChild(authentikButton);
}
function setDashboard(baseUrl)
// creates or finds Dashboard
// basic functionality:
// initializes or finds dashboard div
// prepends new div before document.body.firstChild
function createOrFindDashboard(baseUrl)
{
if (document.getElementById('lit-dashboard'))
{
@ -95,21 +106,22 @@ function setDashboard(baseUrl)
var currentDiv = document.body.firstChild;
document.body.insertBefore(dashboard, currentDiv);
}
// erstelle ein neues div Element
// und gib ihm etwas Inhalt
}
function onGot(item) {
baseUrl = "demo.local-it.org";
if (item.baseUrl) {
baseUrl = item.baseUrl;
}
setDashboard(baseUrl);
createOrFindDashboard(baseUrl);
}
let getting = browser.storage.sync.get("baseUrl");
getting.then(onGot, onError);
// listen to message from background.js
browser.runtime.onMessage.addListener(request => {
doStuff();
return Promise.resolve({response: ""});
if (request.trigger === "extension click")
{
toggleDisplayBoard();
return Promise.resolve({response: ""});
}
});

BIN
icons/favicon48.jpg 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -2,9 +2,9 @@
"manifest_version": 2,
"name": "Dashboard",
"version": "1.0",
"version": "1.1",
"description": "Adds a Dashboard Header before Webpage header.",
"description": "Makes Dashboard available through shortcut to access wekan/nextcloud/authentik instances",
"content_scripts": [
{
@ -13,26 +13,29 @@
"css": [ "css/dashboard.css" ]
}
],
"icons":{
"48": "icons/favicon48.jpg"
},
"web_accessible_resources": [
"css/style.css",
"icons/Nextcloud_Logo.png",
"icons/wekan_logo.png",
"icons/goauthentik_logo.png",
"icons/favicon.jpg"
"icons/favicon48.jpg"
],
"options_ui": {
"page": "options.html"
},
"permissions": ["storage","tabs"],
"browser_specific_settings": {
"gecko": {
"id": "addon@example.com"
"id": "dashboard@viehlieb.org",
"strict_min_version": "58.0"
}
},
"permissions": ["storage","tabs"],
"browser_action": {
"default_icon": "icons/favicon.jpg",
"default_icon": "icons/favicon48.jpg",
"default_title": "Holsteincloud 3.0"
},
"background": {