summaryrefslogtreecommitdiff
path: root/src/gizmo/wasp-bannerads.el
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-03-13 21:30:13 -0400
committerLLLL Colonq <llll@colonq>2025-03-13 21:30:13 -0400
commitb21ecce6645fc17c520b722de3d96e550c77c490 (patch)
treeea43d01bd3e36c36eb7b43945ef662088aee3cb7 /src/gizmo/wasp-bannerads.el
parenta2d075656ca6a07c6263eee588e15cf2ee802995 (diff)
Update
Diffstat (limited to 'src/gizmo/wasp-bannerads.el')
-rw-r--r--src/gizmo/wasp-bannerads.el25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/gizmo/wasp-bannerads.el b/src/gizmo/wasp-bannerads.el
index 2586600e..70f9c8be 100644
--- a/src/gizmo/wasp-bannerads.el
+++ b/src/gizmo/wasp-bannerads.el
@@ -9,6 +9,8 @@
(require 'wasp-utils)
(require 'wasp-chat)
+(defvar w/banner-ad-block nil)
+
(defcustom w/banner-ad-buffer "*wasp-banner-ad*"
"Name of buffer used to display banner ad."
:type '(string)
@@ -32,9 +34,13 @@
(setq-local cursor-type nil)
(let* ((inhibit-read-only t))
(erase-buffer)
- (let* ((paths (f-files (w/asset "bannerads")))
- (path (w/pick-random paths)))
- (w/write (propertize "bannerad" 'display (create-image path nil nil :max-width 555 :max-height 175)))))))
+ (if w/banner-ad-block
+ (w/write "This advertisement was blocked by your adblocker")
+ (let* ((paths (f-files (w/asset "bannerads")))
+ (path (w/pick-random paths))
+ (img (create-image path nil nil :max-width 555 :max-height 175)))
+ (image-animate img nil t)
+ (w/write (propertize "bannerad" 'display img)))))))
(defvar w/banner-ad-timer nil)
(defun w/run-banner-ad-timer ()
@@ -47,5 +53,18 @@
(run-with-timer 60 nil #'w/run-banner-ad-timer)))
(w/run-banner-ad-timer)
+
+(defun w/banner-ad-block ()
+ "Toggle adblock."
+ (setq w/banner-ad-block t)
+ (w/render-banner-ad)
+ (w/model-toggle-set "adblock")
+ (run-with-timer 10 nil
+ (lambda ()
+ (setq w/banner-ad-block nil)
+ (w/model-toggle-unset "adblock")
+ (w/render-banner-ad)))
+ nil)
+
(provide 'wasp-bannerads)
;;; wasp-bannerads.el ends here