Skip to content

Commit 690f94a

Browse files
committed
add debugging section and improve notification titles
1 parent ffb903f commit 690f94a

File tree

4 files changed

+69
-7
lines changed

4 files changed

+69
-7
lines changed

background.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
4444
for (const id of ids) {
4545
showNotification(
4646
id,
47-
`${addedIds.size} ${addedIds.size === 1 ? "neue Anzeige" : "neue Anzeigen"}`,
48-
titleById[id],
47+
`Neue Anzeige (${id})`,
48+
titleById[id] ?? '(keine Beschreibung)',
4949
);
5050
}
5151
} else {

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Immo24 Notifier",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"manifest_version": 3,
55
"description": "Immo24 Notifier extension by Maximilian Hoffmann",
66
"homepage_url": "https://github.com/maxhoffmann/immo-extension",

popup.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
p {
1515
font-size: 11px;
1616
}
17+
.form {
18+
margin-block-start: 1rem;
19+
display: flex;
20+
flex-direction: column;
21+
gap: 0.5rem;
22+
}
1723
details {
1824
margin-block-start: 1rem;
1925
}
@@ -27,14 +33,23 @@ <h2>So geht’s:</h2>
2733
Das funktioniert auch, wenn die Tabs im Hintergrund geöffnet sind und man auf anderen Seiten surft.
2834
</p>
2935
<hr>
30-
<h2>Klicke hier, um Benachrichtigungen zu testen:</h2>
31-
<button>Benachrichtung testen</button>
36+
<h2>Klicke hier, um eine Benachrichtigung zu testen:</h2>
37+
<button id="test-example">Benachrichtung testen</button>
3238
<details>
3339
<summary>keine Benachrichtigung erschienen?</summary>
3440
<p>
3541
Falls beim Klick auf den Button keine Benachrichtigung erscheint, fehlen dem Browser die Berechtigungen Benachrichtigungen zu schicken.
3642
Schau in deinen Browser- oder Systemeinstellungen nach und aktiviere Benachrichtigungen für deinen Browser.
3743
</p>
3844
</details>
45+
<details>
46+
<summary>Debug</summary>
47+
<div class="form">
48+
<input type="text" name="expose1" id="expose1" placeholder="Expose ID 1">
49+
<input type="text" name="expose2" id="expose2" placeholder="Expose ID 2">
50+
<button id="test-one">Eine Benachrichtung testen</button>
51+
<button id="test-multiple">Mehrere Benachrichtungen testen</button>
52+
</div>
53+
</details>
3954
</body>
4055
</html>

popup.js

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,57 @@
11
document.addEventListener("DOMContentLoaded", () => {
2-
document.querySelector("button").addEventListener("click", () => {
3-
chrome.notifications.create({
2+
const firstExpose = document.querySelector('#expose1');
3+
const secondExpose = document.querySelector('#expose2');
4+
5+
firstExpose.addEventListener("input", (event) => {
6+
localStorage.setItem('expose1', event.target.value);
7+
});
8+
secondExpose.addEventListener("input", (event) => {
9+
localStorage.setItem('expose2', event.target.value);
10+
});
11+
12+
if (localStorage.getItem('expose1')) {
13+
firstExpose.value = localStorage.getItem('expose1');
14+
}
15+
if (localStorage.getItem('expose2')) {
16+
secondExpose.value = localStorage.getItem('expose2');
17+
}
18+
19+
document.querySelector("#test-example").addEventListener("click", async () => {
20+
await chrome.notifications.create({
421
type: "basic",
22+
iconUrl: "icon-48.png",
523
title: "x neue Anzeigen!",
624
message: "auf ImmoScout24",
25+
requireInteraction: true,
26+
});
27+
});
28+
document.querySelector("#test-one").addEventListener("click", async () => {
29+
const firstExposeId = firstExpose.value;
30+
31+
await chrome.notifications.create("immo24:" + firstExposeId, {
32+
type: "basic",
733
iconUrl: "icon-48.png",
34+
title: "Test-Anzeige: "+firstExposeId,
35+
message: "auf ImmoScout24",
36+
requireInteraction: true,
37+
});
38+
});
39+
document.querySelector("#test-multiple").addEventListener("click", async () => {
40+
const firstExposeId = firstExpose.value;
41+
const secondExposeId = secondExpose.value;
42+
43+
chrome.notifications.create("immo24:" + firstExposeId, {
44+
type: "basic",
45+
iconUrl: "icon-48.png",
46+
title: "Test-Anzeige: "+firstExposeId,
47+
message: "auf ImmoScout24",
48+
requireInteraction: true,
49+
});
50+
chrome.notifications.create("immo24:" + secondExposeId, {
51+
type: "basic",
52+
iconUrl: "icon-48.png",
53+
title: "Test-Anzeige: "+secondExposeId,
54+
message: "auf ImmoScout24",
855
requireInteraction: true,
956
});
1057
});

0 commit comments

Comments
 (0)