Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Commit 08f1446

Browse files
committed
fix button not appearing and add chrome compatibility(?)(not tested)
1 parent 99d2998 commit 08f1446

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

content_script.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
let engine;
2+
3+
if (window.browser !== undefined) {
4+
engine = browser;
5+
} else {
6+
engine = chrome;
7+
}
8+
19
function addButton() {
210
const sidebar = document.querySelector(".window-sidebar")
311
const button = document.createElement('span');
@@ -29,7 +37,7 @@ const mappings = {
2937

3038
function onClick() {
3139
let trelloApiKey = "afadffe77f745496f80ebb4bf460c615"
32-
browser.storage.local.get().then(result => {
40+
engine.storage.local.get().then(result => {
3341
const trelloToken = result.trello
3442
const togglToken = result.toggl
3543

@@ -136,9 +144,11 @@ function onClick() {
136144
})
137145
})
138146

139-
window.addEventListener("pushstate", function () {
140-
if (window.location.pathname.startsWith("/c/")) {
141-
addButton()
142-
}
143-
})
147+
144148
}
149+
150+
window.addEventListener("pushstate", function () {
151+
if (window.location.pathname.startsWith("/c/")) {
152+
addButton()
153+
}
154+
})

options/script.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1+
let engine;
2+
3+
if (window.browser !== undefined) {
4+
engine = browser;
5+
} else {
6+
engine = chrome;
7+
}
8+
19
const trelloTextField = document.querySelector("#trello_token")
210
const togglTextField = document.querySelector("#toggl_token")
311

412
trelloTextField.addEventListener("input", onChange)
513
togglTextField.addEventListener("input", onChange)
614

715
function onChange() {
8-
browser.storage.local.set({
16+
engine.storage.local.set({
917
"trello": trelloTextField.value,
1018
"toggl": togglTextField.value
1119
})
1220
console.log(`set trello token to ${togglTextField.value}`)
1321
console.log(`set toggl token to ${togglTextField.value}`)
1422
}
1523

16-
browser.storage.local.get().then(result => {
24+
engine.storage.local.get().then(result => {
1725
trelloTextField.value = result["trello"]
1826
togglTextField.value = result["toggl"]
1927
})

0 commit comments

Comments
 (0)