Skip to content

Commit 825b38c

Browse files
committed
add failiure message and check for chapter
1 parent 2bd1d07 commit 825b38c

4 files changed

Lines changed: 129 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ You will need both the Zotero Connector as well as this plugin when trying to im
2323

2424
Importing chapters with the Zotero Connector however will lead to incomplete information, only use it for the other content types.
2525

26+
Remember to have Zotero running. Otherwise the extension will not work!
27+
2628

2729
## Thanks
2830

popup.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
(async () => {
2-
32
console.log("hi");
43

54
const [tab] = await chrome.tabs.query({
65
active: true,
76
currentWindow: true,
87
});
98

10-
if (!tab.url.includes("opac.regesta-imperii.de/lang_de/")) {
9+
if (!tab.url.includes("opac.regesta-imperii.de/lang_de/")) {
1110
chrome.tabs.update({
1211
url: "https://opac.regesta-imperii.de/lang_de/",
1312
});
1413
}
1514

15+
if (!tab.url.includes("buchbeitrag")) {
16+
// show message in popup that extension only works for chapters
17+
const msg = document.createElement("div");
18+
msg.textContent = "Die extension funktioniert nur für Buchbeiträge.";
19+
msg.style.padding = "12px";
20+
msg.style.fontFamily = "sans-serif";
21+
msg.style.fontSize = "14px";
22+
document.body.appendChild(msg);
23+
return;
24+
}
25+
1626
const response = await chrome.tabs.sendMessage(tab.id, {
1727
type: "START",
1828
});

public/failiure.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!DOCTYPE html>
2+
<html lang="de">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Fehler - Entschuldigung</title>
7+
<style>
8+
* {
9+
margin: 0;
10+
padding: 0;
11+
box-sizing: border-box;
12+
}
13+
14+
body {
15+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
16+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
17+
min-height: 100vh;
18+
display: flex;
19+
justify-content: center;
20+
align-items: center;
21+
padding: 20px;
22+
}
23+
24+
.container {
25+
background: white;
26+
border-radius: 10px;
27+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
28+
padding: 50px;
29+
max-width: 600px;
30+
text-align: center;
31+
}
32+
33+
.error-icon {
34+
font-size: 80px;
35+
margin-bottom: 20px;
36+
}
37+
38+
h1 {
39+
color: #333;
40+
font-size: 32px;
41+
margin-bottom: 15px;
42+
}
43+
44+
.subtitle {
45+
color: #666;
46+
font-size: 18px;
47+
margin-bottom: 30px;
48+
line-height: 1.6;
49+
}
50+
51+
.message {
52+
background: #f5f5f5;
53+
border-left: 4px solid #667eea;
54+
padding: 20px;
55+
margin: 30px 0;
56+
text-align: left;
57+
border-radius: 5px;
58+
color: #555;
59+
}
60+
61+
.button-group {
62+
display: flex;
63+
gap: 10px;
64+
justify-content: center;
65+
margin-top: 30px;
66+
flex-wrap: wrap;
67+
}
68+
69+
button {
70+
padding: 12px 30px;
71+
font-size: 16px;
72+
border: none;
73+
border-radius: 5px;
74+
cursor: pointer;
75+
transition: all 0.3s ease;
76+
}
77+
78+
.btn-home {
79+
background: #667eea;
80+
color: white;
81+
}
82+
83+
.btn-home:hover {
84+
background: #5568d3;
85+
transform: translateY(-2px);
86+
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
87+
}
88+
89+
.btn-retry {
90+
background: #f0f0f0;
91+
color: #333;
92+
border: 2px solid #ddd;
93+
}
94+
95+
.btn-retry:hover {
96+
background: #e8e8e8;
97+
border-color: #667eea;
98+
}
99+
</style>
100+
</head>
101+
<body>
102+
<div class="container">
103+
<div class="error-icon">😔</div>
104+
<h1>Entschuldigung!</h1>
105+
<p class="subtitle">Das hat leider nicht funktioniert.</p>
106+
107+
108+
<div class="button-group">
109+
<button class="btn-home" onclick="window.location.href='https://github.com/theRatramnus/riopac-add-chapter-chrome/issues'">Auf GitHub melden</button>
110+
</div>
111+
</body>
112+
</html>

service-worker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,10 @@ async function postToZoteroSaveItems(payload) {
291291
}
292292
}
293293

294+
chrome.tabs.create({ url: chrome.runtime.getURL("failiure.html") });
295+
294296
throw new Error(
295297
`Konnte Zotero /connector/saveItems nicht erreichen oder speichern. ${errors.join(" | ")}`,
296298
);
299+
297300
}

0 commit comments

Comments
 (0)