Überarbeitung: HTML-Templates aus Repo entfernt, Plugin verbessert
- HTML-Vorlagen werden separat verteilt (nicht mehr im Plugin-Repo) - background.js: insertText API für korrekte Darstellung im Composer - background.js: automatischer Wechsel zu HTML-Modus bei Plain-Text - Options-Seite: komplett überarbeitetes UI mit Hotel-Branding - Popup: deutsches UI, gestylte Template-Auswahl - Notifications auf Deutsch - Fertige XPI im Repo
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Für weitere Fragen stehen wir Ihnen gern zur Verfügung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Mit freundlichen Grüßen</p>
|
||||
@@ -1,6 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">vielen Dank für Ihre Anfrage.<br>
|
||||
Leider sind in dem gewünschten Zeitraum unsere Kapazitäten bereits ausgeschöpft. Eventuell sind Sie noch flexibel und wir dürfen einen alternativen Termin für Sie prüfen.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Bei weiteren Fragen oder Anregungen stehen wir Ihnen sehr gerne zur Verfügung.</p>
|
||||
@@ -1,9 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">bezugnehmend auf unser Angebot vom [Datum] bis [Datum] möchte ich Ihnen mitteilen, dass heute das Optionsdatum abläuft und wir das Angebot morgen aus dem System nehmen werden.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Daher freuen wir uns über eine schnelle Rückmeldung von Ihnen.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Bei weiteren Fragen zögern Sie bitte nicht, sich bei uns zu melden.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,8 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">vielen Dank für Ihre Anfrage.<br>
|
||||
Im Anhang erhalten Sie Ihr Reservierungsangebot.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Um eine verbindliche Reservierung vornehmen zu können, benötigen wir Ihre Anschrift und eine Telefonnummer.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Bei weiteren Fragen oder Anregungen stehen wir Ihnen sehr gerne zur Verfügung.</p>
|
||||
@@ -1,11 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">wir möchten Sie freundlich darüber informieren, dass am [Datum] unsere Abendgastronomie sowie die Bar geschlossen bleiben.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Selbstverständlich haben wir für Sie eine Alternative vorgesehen. An der Rezeption erhalten Sie einen Gutschein für das Nachbarhotel (Fußweg ca. 200m) und einen Tisch reservieren wir auch gerne für Sie.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Weitere Getränke am Abend erhalten Sie bei uns an der Rezeption.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Bei Fragen stehen wir Ihnen gerne zur Verfügung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,5 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">im Anhang erhalten Sie wie gewünscht die Rechnung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Für weitere Fragen stehen wir Ihnen gern zur Verfügung.</p>
|
||||
@@ -1,6 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">vielen Dank für Ihre Buchung.<br>
|
||||
Im Anhang erhalten Sie die Reservierungsbestätigung. Für Fragen stehen wir Ihnen gern zur Verfügung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,15 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">vielen Dank für Ihre Anfrage und Ihr Interesse an unserem Fahrradverleih. Wir freuen uns, dass Sie während Ihres Aufenthalts die Umgebung aktiv erkunden möchten.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Gerne möchten wir Sie darauf hinweisen, dass unsere Fahrräder ausschließlich vor Ort und nach Verfügbarkeit verliehen werden. Eine Vorabreservierung ist aus betriebsorganisatorischen Gründen leider nicht möglich. Wir bitten um Ihr Verständnis, dass wir an dieser Regelung keine Ausnahmen machen können.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Unsere eBikes befinden sich derzeit in der Wartung, und leider können wir aktuell noch nicht absehen, wann sie wieder zur Verfügung stehen. Damit Sie dennoch nicht auf ein eBike verzichten müssen, empfehlen wir Ihnen den Fahrradverleih <b>Fahrrad Sandau</b>, der hochwertige eBikes anbietet und diese bei Bedarf direkt zu unserem Hotel liefert. Sie erreichen den Verleih unter:</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sohlstraße 23, 29633 Münster / 05192 2458 / info@fahrrad-sandau.de / <a href="https://www.fahrrad-sandau.de/">www.fahrrad-sandau.de</a></p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Wir hoffen, Ihnen mit dieser Alternative eine angenehme Lösung anbieten zu können, und stehen Ihnen selbstverständlich jederzeit für weitere Fragen zur Verfügung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Wir freuen uns darauf, Sie bald bei uns begrüßen zu dürfen, und wünschen Ihnen schon jetzt eine wunderbare Zeit bei uns.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,11 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">es freut mich Ihnen mitzuteilen, dass Ihr [Gegenstand] gefunden wurde.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Gerne schicken wir Ihnen dieses versichert als Paket für 7,69 EUR zu.<br>
|
||||
Bitte teilen Sie uns hierfür die gewünschte Versandart sowie Ihre Adresse mit.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Nach Eingang des Betrages auf unserem u.g. Konto werden wir die Sendung an die Post übergeben.<br>
|
||||
Wir freuen uns auf Ihre Rückmeldung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,9 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">gerne haben wir Rücksprache mit unserem Housekeeping-Team bezüglich Ihres vermissten [Gegenstand] gehalten.<br>
|
||||
Dieser wurde leider nicht gefunden oder bei uns abgegeben.<br>
|
||||
Wir wünschen weiterhin noch viel Erfolg bei der Suche und hoffen, dass er sich wieder anfindet.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Bei weiteren Fragen stehen wir Ihnen sehr gerne zur Verfügung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,9 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte Damen und Herren,</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">wir möchten Sie freundlich darüber informieren, dass am [Datum] unsere Abendgastronomie sowie unsere Bar geschlossen bleiben.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Selbstverständlich sind wir Ihnen gerne bei der Wahl eines Restaurants vor Ort an der Rezeption behilflich.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Bei Fragen stehen wir Ihnen gerne zur Verfügung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,7 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">bitte beachten Sie, dass wir aktuell keine schriftlichen Kostenübernahmen mehr annehmen.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sie können uns jedoch gerne die Kreditkartendaten (Kartennummer, Gültigkeit, CVC) zukommen lassen, wir buchen dann den Betrag direkt ab. Alternativ kann der Gast auch vor Ort bezahlen und die Rechnung anschließend selbst einreichen.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,8 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">vielen Dank für Ihre Buchung eines Zimmers vom [Datum] bis [Datum].<br>
|
||||
Gern bestätigen wir Ihnen wie gewünscht und freuen uns bereits auf Ihre Anreise.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Eine kostenfreie Stornierung ist bis 3 Tage vor Anreise möglich.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Für weitere Fragen stehen wir Ihnen gern zur Verfügung.</p>
|
||||
@@ -1,19 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte Damen und Herren,</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">wir möchten Sie freundlich darüber informieren, dass am [Datum] unsere Abendgastronomie sowie die Bar geschlossen bleiben.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Selbstverständlich haben wir für die Gäste eine Alternative vorgesehen. Die Gäste sollen sich dann bitte bei uns an der Rezeption melden.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Weitere Getränke am Abend erhalten die Gäste bei uns an der Rezeption.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Es sind folgende Gäste betroffen:</p>
|
||||
<ul style="font-family:Calibri,sans-serif;font-size:11pt;">
|
||||
<li>[Name]</li>
|
||||
<li>[Name]</li>
|
||||
</ul>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Wir möchten Sie freundlich darum bitten, die oben genannten Gäste darüber zu informieren.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Bei Fragen stehen wir Ihnen gern zur Verfügung.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:black;">Herzliche Grüße aus Soltau</p>
|
||||
@@ -1,6 +0,0 @@
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Sehr geehrte/r [Anrede Name],</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">wir bestätigen hiermit den Erhalt Ihrer Stornierung und die kostenfreie Aufhebung Ihrer Reservierung.<br>
|
||||
Falls Sie zu einem späteren Zeitpunkt erneut bei uns buchen möchten, freuen wir uns, Sie wieder begrüßen zu dürfen.</p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;"> </p>
|
||||
<p style="margin:0;font-family:Calibri,sans-serif;font-size:11pt;">Für weitere Fragen stehen wir Ihnen gern zur Verfügung.</p>
|
||||
157
background.js
157
background.js
@@ -1,61 +1,96 @@
|
||||
// Sluša poruke iz popupa
|
||||
browser.runtime.onMessage.addListener(async msg => {
|
||||
if (msg.action !== 'insertTemplate') return;
|
||||
try {
|
||||
// 1. Nađi aktivni Compose tab
|
||||
const [tab] = await browser.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true,
|
||||
windowType: 'messageCompose',
|
||||
});
|
||||
if (!tab) throw new Error('Nije pronađen Compose tab');
|
||||
// 2. Dohvati postojeći sadržaj
|
||||
const details = await browser.compose.getComposeDetails(tab.id);
|
||||
// 3. Spoji stari i novi tekst
|
||||
let newBody;
|
||||
if (details.isPlainText) {
|
||||
// 1. Grab existing text
|
||||
const old = details.plainTextBody || '';
|
||||
|
||||
// 2. Build new body by prepending with two-line break spacer
|
||||
// If there's no old content, just use msg.text
|
||||
newBody = msg.text + (old ? '\n' + old : '');
|
||||
|
||||
// 3. Set the updated plain-text body
|
||||
await browser.compose.setComposeDetails(tab.id, {
|
||||
plainTextBody: newBody,
|
||||
});
|
||||
} else {
|
||||
const old = details.body || '';
|
||||
// If content already contains HTML tags, use as-is; otherwise convert newlines
|
||||
const htmlTpl = msg.text.includes('<') ? msg.text : msg.text.replace(/\n/g, '<br>');
|
||||
const bodyTag = '<body';
|
||||
const bodyIdx = old.indexOf(bodyTag);
|
||||
|
||||
if (bodyIdx !== -1) {
|
||||
const insertAt = old.indexOf('>', bodyIdx) + 1;
|
||||
newBody =
|
||||
old.slice(0, insertAt) + '\n' + htmlTpl + '\n' + old.slice(insertAt);
|
||||
} else {
|
||||
newBody = htmlTpl + '<br>' + old;
|
||||
}
|
||||
|
||||
await browser.compose.setComposeDetails(tab.id, { body: newBody });
|
||||
}
|
||||
// 4. Obavijest korisniku
|
||||
await browser.notifications.create({
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/icon.png'),
|
||||
title: 'Template inserted',
|
||||
message: 'Sucessfully',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('background.js error:', e);
|
||||
browser.notifications.create({
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/icon.png'),
|
||||
title: 'Error on inserting!',
|
||||
message: e.message,
|
||||
});
|
||||
}
|
||||
});
|
||||
browser.runtime.onMessage.addListener(async msg => {
|
||||
if (msg.action !== 'insertTemplate') return;
|
||||
try {
|
||||
const [tab] = await browser.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true,
|
||||
windowType: 'messageCompose',
|
||||
});
|
||||
if (!tab) throw new Error('Kein Compose-Fenster gefunden');
|
||||
|
||||
const details = await browser.compose.getComposeDetails(tab.id);
|
||||
const isHtmlTemplate = msg.text.includes('<');
|
||||
|
||||
// If compose is plain text but template is HTML, switch to HTML mode first
|
||||
if (details.isPlainText && isHtmlTemplate) {
|
||||
await browser.compose.setComposeDetails(tab.id, { isPlainText: false });
|
||||
}
|
||||
|
||||
if (details.isPlainText && !isHtmlTemplate) {
|
||||
// Plain text template in plain text mode - use old method
|
||||
const old = details.plainTextBody || '';
|
||||
const newBody = msg.text + (old ? '\n' + old : '');
|
||||
await browser.compose.setComposeDetails(tab.id, { plainTextBody: newBody });
|
||||
} else {
|
||||
// HTML mode: use insertText API to go through the editor's rendering pipeline
|
||||
const htmlContent = isHtmlTemplate ? msg.text : msg.text.replace(/\n/g, '<br>');
|
||||
|
||||
// Move cursor to beginning of body first via script injection
|
||||
await browser.tabs.executeScript(tab.id, {
|
||||
code: `
|
||||
const editor = document.getElementById('messageEditor');
|
||||
const editorDoc = editor ? editor.contentDocument : document;
|
||||
const body = editorDoc.body;
|
||||
if (body) {
|
||||
const range = editorDoc.createRange();
|
||||
range.setStart(body, 0);
|
||||
range.collapse(true);
|
||||
const sel = editorDoc.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
}
|
||||
`
|
||||
}).catch(() => {
|
||||
// Fallback: some TB versions structure the editor differently
|
||||
});
|
||||
|
||||
// Insert HTML at cursor position - this goes through the editor's render pipeline
|
||||
await browser.compose.insertText(tab.id, htmlContent + '<br>', { insertAsText: false });
|
||||
}
|
||||
|
||||
await browser.notifications.create({
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/icon.png'),
|
||||
title: 'Vorlage eingefügt',
|
||||
message: 'Erfolgreich',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('background.js error:', e);
|
||||
|
||||
// Fallback: if insertText fails, try setComposeDetails
|
||||
try {
|
||||
const [tab] = await browser.tabs.query({
|
||||
active: true, currentWindow: true, windowType: 'messageCompose',
|
||||
});
|
||||
if (tab) {
|
||||
const details = await browser.compose.getComposeDetails(tab.id);
|
||||
const old = details.body || '';
|
||||
const htmlTpl = msg.text.includes('<') ? msg.text : msg.text.replace(/\n/g, '<br>');
|
||||
const bodyIdx = old.indexOf('<body');
|
||||
let newBody;
|
||||
if (bodyIdx !== -1) {
|
||||
const insertAt = old.indexOf('>', bodyIdx) + 1;
|
||||
newBody = old.slice(0, insertAt) + '\n' + htmlTpl + '\n' + old.slice(insertAt);
|
||||
} else {
|
||||
newBody = htmlTpl + '<br>' + old;
|
||||
}
|
||||
await browser.compose.setComposeDetails(tab.id, { body: newBody });
|
||||
|
||||
await browser.notifications.create({
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/icon.png'),
|
||||
title: 'Vorlage eingefügt',
|
||||
message: 'Erfolgreich (Fallback)',
|
||||
});
|
||||
}
|
||||
} catch (e2) {
|
||||
console.error('background.js fallback error:', e2);
|
||||
browser.notifications.create({
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/icon.png'),
|
||||
title: 'Fehler beim Einfügen',
|
||||
message: e2.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BIN
templates-reply-hotel.xpi
Normal file
BIN
templates-reply-hotel.xpi
Normal file
Binary file not shown.
@@ -1,57 +1,248 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Manage Templates</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; padding: 20px; }
|
||||
#templates-list { margin-top: 20px; border: 1px solid #ccc; padding: 10px; }
|
||||
.template-item { padding: 10px; border-bottom: 1px dashed #eee; display: flex; justify-content: space-between; align-items: center; }
|
||||
.template-item:last-child { border-bottom: none; }
|
||||
.template-name { font-weight: bold; }
|
||||
button { margin-left: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Templates manager</h2>
|
||||
|
||||
<fieldset>
|
||||
<legend>HTML-Dateien importieren</legend>
|
||||
<p style="font-size: 0.9em; color: #555;">Wähle eine oder mehrere .html Dateien aus (z.B. vom Netzlaufwerk). Dateiname = Template-Name. Bestehende Templates mit gleichem Namen werden überschrieben.</p>
|
||||
<input type="file" id="import-files" accept=".html,.htm" multiple style="margin-bottom: 10px;">
|
||||
<br>
|
||||
<button type="button" id="import-button">Importieren</button>
|
||||
<span id="import-status" style="margin-left: 10px; color: green; display: none;"></span>
|
||||
</fieldset>
|
||||
|
||||
<br>
|
||||
|
||||
<fieldset>
|
||||
<legend id="form-legend">New Template</legend>
|
||||
<form id="template-form">
|
||||
<input type="hidden" id="template-id">
|
||||
|
||||
<label for="template-name">Title:</label><br>
|
||||
<input type="text" id="template-name" required style="width: 98%; margin-bottom: 10px;"><br>
|
||||
|
||||
<label for="template-content">Text (HTML/Tekst):</label><br>
|
||||
<textarea id="template-content" required rows="10" style="width: 98%; margin-bottom: 10px;"></textarea><br>
|
||||
|
||||
<button type="submit" id="save-button">Save</button>
|
||||
<button type="button" id="cancel-edit" style="display: none;">Discard</button>
|
||||
</form>
|
||||
</fieldset>
|
||||
|
||||
<h3>Existing Templates</h3>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<button type="button" id="select-all-button">Alle auswählen</button>
|
||||
<button type="button" id="delete-selected-button" style="color: red;">Ausgewählte löschen</button>
|
||||
</div>
|
||||
<div id="templates-list">
|
||||
<p id="no-templates">There is no saved templates.</p>
|
||||
</div>
|
||||
|
||||
<script src="templates_options.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Vorlagen verwalten</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: "Segoe UI", -apple-system, sans-serif;
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
padding: 24px 32px;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
color: #4a7c59;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 2px solid #4a7c59;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-top: 24px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/* Cards */
|
||||
.card {
|
||||
background: white;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #4a7c59;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.card-desc {
|
||||
font-size: 12.5px;
|
||||
color: #777;
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* Form elements */
|
||||
label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #555;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
input[type="text"], textarea {
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #d0d0d0;
|
||||
border-radius: 6px;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
margin-bottom: 10px;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
|
||||
input[type="text"]:focus, textarea:focus {
|
||||
outline: none;
|
||||
border-color: #4a7c59;
|
||||
box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.15);
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
font-size: 13px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #4a7c59;
|
||||
color: white;
|
||||
}
|
||||
.btn-primary:hover { background: #3d6a4b; }
|
||||
|
||||
.btn-secondary {
|
||||
background: #e8e8e8;
|
||||
color: #333;
|
||||
}
|
||||
.btn-secondary:hover { background: #d8d8d8; }
|
||||
|
||||
.btn-danger {
|
||||
background: white;
|
||||
color: #c0392b;
|
||||
border: 1px solid #e0b4b0;
|
||||
}
|
||||
.btn-danger:hover { background: #fdf0ef; border-color: #c0392b; }
|
||||
|
||||
.btn + .btn { margin-left: 8px; }
|
||||
|
||||
/* Template list */
|
||||
#templates-list {
|
||||
background: white;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.template-item {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
transition: background 0.1s;
|
||||
}
|
||||
|
||||
.template-item:last-child { border-bottom: none; }
|
||||
|
||||
.template-item:hover { background: #fafff8; }
|
||||
|
||||
.template-item input[type="checkbox"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-right: 12px;
|
||||
accent-color: #4a7c59;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.template-name {
|
||||
font-weight: 500;
|
||||
font-size: 13.5px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.template-actions { display: flex; gap: 6px; }
|
||||
|
||||
.template-actions button {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 5px;
|
||||
background: white;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
transition: background 0.1s, border-color 0.1s;
|
||||
}
|
||||
|
||||
.template-actions .edit-btn:hover {
|
||||
background: #e8f0eb;
|
||||
border-color: #4a7c59;
|
||||
color: #4a7c59;
|
||||
}
|
||||
|
||||
.template-actions .delete-btn {
|
||||
color: #c0392b;
|
||||
}
|
||||
.template-actions .delete-btn:hover {
|
||||
background: #fdf0ef;
|
||||
border-color: #c0392b;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
#no-templates {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
margin-left: 10px;
|
||||
font-size: 12.5px;
|
||||
font-weight: 500;
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Vorlagen verwalten</h2>
|
||||
|
||||
<!-- Import Section -->
|
||||
<div class="card">
|
||||
<div class="card-title">HTML-Dateien importieren</div>
|
||||
<div class="card-desc">Wähle eine oder mehrere .html Dateien aus (z.B. vom Netzlaufwerk).<br>Dateiname = Vorlagen-Name. Bestehende Vorlagen mit gleichem Namen werden überschrieben.</div>
|
||||
<input type="file" id="import-files" accept=".html,.htm" multiple>
|
||||
<br>
|
||||
<button type="button" class="btn btn-primary" id="import-button">Importieren</button>
|
||||
<span id="import-status" class="status-badge"></span>
|
||||
</div>
|
||||
|
||||
<!-- Add/Edit Section -->
|
||||
<div class="card">
|
||||
<div class="card-title" id="form-legend">Neue Vorlage erstellen</div>
|
||||
<form id="template-form">
|
||||
<input type="hidden" id="template-id">
|
||||
<label for="template-name">Titel</label>
|
||||
<input type="text" id="template-name" required placeholder="z.B. Buchungsbestätigung">
|
||||
<label for="template-content">Inhalt (HTML)</label>
|
||||
<textarea id="template-content" required placeholder="<p>Sehr geehrte/r ...</p>"></textarea>
|
||||
<button type="submit" class="btn btn-primary" id="save-button">Speichern</button>
|
||||
<button type="button" class="btn btn-secondary" id="cancel-edit" style="display: none;">Abbrechen</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Template List -->
|
||||
<h3>Gespeicherte Vorlagen</h3>
|
||||
<div class="toolbar">
|
||||
<button type="button" class="btn btn-secondary" id="select-all-button">Alle auswählen</button>
|
||||
<button type="button" class="btn btn-danger" id="delete-selected-button">Ausgewählte löschen</button>
|
||||
</div>
|
||||
<div id="templates-list">
|
||||
<p id="no-templates">Keine Vorlagen vorhanden.</p>
|
||||
</div>
|
||||
|
||||
<script src="templates_options.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -57,11 +57,11 @@ function renderTemplates(templates) {
|
||||
const item = document.createElement('div');
|
||||
item.className = 'template-item';
|
||||
item.innerHTML = `
|
||||
<input type="checkbox" class="template-checkbox" data-id="${template.id}" style="margin-right: 10px;">
|
||||
<input type="checkbox" class="template-checkbox" data-id="${template.id}">
|
||||
<span class="template-name">${template.name}</span>
|
||||
<div>
|
||||
<button data-id="${template.id}" class="edit-btn">Edit</button>
|
||||
<button data-id="${template.id}" class="delete-btn">Delete</button>
|
||||
<div class="template-actions">
|
||||
<button data-id="${template.id}" class="edit-btn">Bearbeiten</button>
|
||||
<button data-id="${template.id}" class="delete-btn">Löschen</button>
|
||||
</div>
|
||||
`;
|
||||
templateList.appendChild(item);
|
||||
@@ -109,7 +109,7 @@ templateForm.addEventListener('submit', async (e) => {
|
||||
* Deletes a template
|
||||
*/
|
||||
async function handleDelete(e) {
|
||||
if (!confirm('Are you sure you want to delete this template?')) {
|
||||
if (!confirm('Diese Vorlage wirklich löschen?')) {
|
||||
return;
|
||||
}
|
||||
const idToDelete = e.target.dataset.id;
|
||||
@@ -136,8 +136,8 @@ async function handleEdit(e) {
|
||||
document.getElementById('template-content').value = template.content;
|
||||
|
||||
// Update UI to signal editing
|
||||
formLegend.textContent = 'Edit Template';
|
||||
saveButton.textContent = 'Update Template';
|
||||
formLegend.textContent = 'Vorlage bearbeiten';
|
||||
saveButton.textContent = 'Aktualisieren';
|
||||
cancelButton.style.display = 'inline';
|
||||
|
||||
// Scroll to the top of the form
|
||||
@@ -152,8 +152,8 @@ function resetForm() {
|
||||
templateForm.reset();
|
||||
document.getElementById('template-id').value = '';
|
||||
|
||||
formLegend.textContent = 'Add New Template';
|
||||
saveButton.textContent = 'Save Template';
|
||||
formLegend.textContent = 'Neue Vorlage erstellen';
|
||||
saveButton.textContent = 'Speichern';
|
||||
cancelButton.style.display = 'none';
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ document.getElementById('import-button').addEventListener('click', async () => {
|
||||
await saveTemplates(templates);
|
||||
renderTemplates(templates);
|
||||
|
||||
statusEl.textContent = `${importCount} Template(s) importiert!`;
|
||||
statusEl.textContent = `${importCount} Vorlage(n) importiert!`;
|
||||
statusEl.style.color = 'green';
|
||||
statusEl.style.display = 'inline';
|
||||
fileInput.value = '';
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:10pt;color:#95A322;font-weight:bold;font-style:italic;">Verehrte Gäste,</p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:9pt;font-style:italic;">die Stadt Soltau erhebt für alle Übernachtungen, die ab dem 01.01.2026 gebucht werden, eine Übernachtungssteuer in Höhe von 1,75 % pro Zimmer/Übernachtung, zzgl. 7 % MwSt.</p>
|
||||
<p style="margin:0;font-family:Verdana,sans-serif;font-size:9pt;font-style:italic;">Diese Abgabe wird separat in Rechnung gestellt und von uns an die Stadt Soltau abgeführt.</p>
|
||||
Reference in New Issue
Block a user