Compare commits
3 commits
b41bf2b183
...
fc2ad7afad
Author | SHA1 | Date | |
---|---|---|---|
fc2ad7afad | |||
4f717f7c80 | |||
a1cf58d8d3 |
1
package-lock.json
generated
1
package-lock.json
generated
|
@ -7,6 +7,7 @@
|
|||
"": {
|
||||
"name": "usrspace-browser-addon",
|
||||
"version": "0.8.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"webextension-polyfill": "^0.10.0"
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
"scripts": {
|
||||
"copy-browser-polyfill": "cp node_modules/webextension-polyfill/dist/browser-polyfill.js src/browser-polyfill.js",
|
||||
"copy-version": "sed -i 's/^\t\"version\": \".*\",$/\t\"version\": \"'$(rg '^\t\"version\": \"(.+)\",$' -r '$1' < package.json)'\",/' manifest.json",
|
||||
"build": "web-ext build -o -n \"_usr_space-{version}.zip\" -i README.md package.json package-lock.json",
|
||||
"prebuild": "cp LICENSE.txt src/",
|
||||
"build": "web-ext build -o -s src/ -n \"_usr_space-{version}.zip\"",
|
||||
"postbuild": "rm src/LICENSE.txt",
|
||||
"test": "echo \"Error: no test specified\" && exit 0",
|
||||
"postinstall": "npm run copy-browser-polyfill",
|
||||
"preversion": "npm test",
|
||||
|
|
|
@ -45,19 +45,20 @@ async function fetchNewData() {
|
|||
await browser.browserAction.setBadgeText({text: badgeText});
|
||||
await browser.browserAction.setBadgeBackgroundColor({color: badgeBgColor});
|
||||
|
||||
if (window.spaceApi && window.spaceApi.state.open !== spaceApiJson.state.open) {
|
||||
const spaceApi = JSON.parse(localStorage.getItem('spaceApi'));
|
||||
if (spaceApi && spaceApi.state.open !== spaceApiJson.state.open) {
|
||||
const state = browser.i18n.getMessage(spaceApiJson.state.open ? 'open' : 'closed');
|
||||
await browser.notifications.create('status-change', {
|
||||
type: 'basic',
|
||||
title: browser.i18n.getMessage('stateNotificationTitle'),
|
||||
message: browser.i18n.getMessage('stateNotificationMessage', state),
|
||||
iconUrl: browser.runtime.getURL('src/icons/favicon.svg')
|
||||
iconUrl: browser.runtime.getURL('icons/favicon.svg')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
window.calendar = calendarJson;
|
||||
window.spaceApi = spaceApiJson;
|
||||
localStorage.setItem('calendar', JSON.stringify(calendarJson));
|
||||
localStorage.setItem('spaceApi', JSON.stringify(spaceApiJson));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
"description": "__MSG_extensionDescription__",
|
||||
"version": "0.8.0",
|
||||
"icons": {
|
||||
"48": "src/icons/favicon.svg",
|
||||
"96": "src/icons/favicon.svg"
|
||||
"48": "icons/favicon.svg",
|
||||
"96": "icons/favicon.svg"
|
||||
},
|
||||
"background": {
|
||||
"page": "src/background.html"
|
||||
"page": "background.html"
|
||||
},
|
||||
"browser_action": {
|
||||
"browser_style": true,
|
||||
"default_title": "__MSG_buttonTitle__",
|
||||
"default_icon": "src/icons/favicon.svg",
|
||||
"default_icon": "icons/favicon.svg",
|
||||
"default_area": "navbar",
|
||||
"default_popup": "src/popup.html"
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
"default_locale": "de",
|
||||
"permissions": [
|
17
src/popup.js
17
src/popup.js
|
@ -49,20 +49,21 @@ async function init() {
|
|||
linkElement.addEventListener('click', linkElementClickListener);
|
||||
});
|
||||
|
||||
try {
|
||||
const page = await browser.runtime.getBackgroundPage();
|
||||
const calendar = JSON.parse(localStorage.getItem('calendar'));
|
||||
const spaceApi = JSON.parse(localStorage.getItem('spaceApi'));
|
||||
|
||||
updateNextEvent(page.calendar);
|
||||
updateSpaceApiJson(page.spaceApi);
|
||||
updateState(page.spaceApi);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (calendar) {
|
||||
updateNextEvent(calendar);
|
||||
}
|
||||
if (spaceApi) {
|
||||
updateSpaceApiJson(spaceApi);
|
||||
updateState(spaceApi);
|
||||
}
|
||||
}
|
||||
init();
|
||||
|
||||
/**
|
||||
* @param {object} nextEvents
|
||||
* @param {Array<object>} nextEvents
|
||||
*/
|
||||
function updateNextEvent(nextEvents) {
|
||||
const calendarElement = document.getElementById('calendar');
|
||||
|
|
Loading…
Reference in a new issue