commit 8d170a5bcf1c30b59cc78783c07edf351e214978
parent 90c4b0f8296778e7c33225b47c8008855e64648c
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Wed, 9 Apr 2025 20:29:41 +0200
fix: filter out div's as well
Diffstat:
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/assets/js/push.js b/assets/js/push.js
@@ -0,0 +1,46 @@
+/* Function to send notifiations to the user
+ * adjusted from example code in:
+ * https://developer.mozilla.org/en-US/docs/Web/API/Notification
+ */
+
+function send_notification(title, body_text, url) {
+
+ if (!("Notification" in window)) {
+
+ // Send alert, if the browser does not support notifications
+ alert("This browser does not support desktop notification");
+
+ } else if (Notification.permission === "granted") {
+
+ // send notification, if the user allowed them
+ create_notification(title, body_text, url);
+
+ } else if (Notification.permission !== "denied") {
+
+ // ask for notification permission, if it neither denied nor granted
+ // send notification, if the user grants permission
+ Notification.requestPermission().then((permission) => {
+ if (permission === "granted") {
+ create_notification(title, body_text, url);
+ }
+ });
+
+ }
+}
+
+function create_notification(title, body_text, url) {
+
+ // Create notification object
+ const notification = new Notification(
+ title,
+ {
+ body: body_text,
+ icon: "/assets/favicon.png",
+ requireInteraction: true
+ }
+ );
+
+ // add onclick event for opening the given URL
+ notification.onclick = () => window.open(url);
+
+}
diff --git a/scripts/run.sh b/scripts/run.sh
@@ -30,7 +30,7 @@ sed -E \
-e 's/<br[^a-z]*[^>]*>//g' \
-e 's/<p[^a-z]*[^>]*><\/p>//g' \
-e 's/<a\ [^<]+<\/a><\!--end-->/<\!--end-->/g' \
- -e 's/(<\!--start-->)(([^<]*)(<a[^>]+>)*([^<]*)(<\/a>)([^<]*))+.*(<\!--end-->)$/\1\3\5\7\8/g' \
+ -e 's/(<\!--start-->)(([^<]*)(<(a|div)[^>]*>)*([^<]*)(<\/(a|div)>)([^<]*))+.*/\1\3\6\9<\!--end-->/g' \
-i "$page_file"
# insert link to rss/xml file