aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-10-21 23:44:29 +1100
committerYuchen Pei <hi@ypei.me>2022-10-21 23:44:29 +1100
commit9c95bcb74ffccbbc50a529dbbec81e24ddce6baf (patch)
tree0fcc2a25224bdd06e511f56bbe6592d287bda0db
parent544187e3e7ee057b97e2048f71f4e19396884b50 (diff)
adding an example url rewrite function
-rw-r--r--luwak.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/luwak.el b/luwak.el
index 08eb793..93b3d0f 100644
--- a/luwak.el
+++ b/luwak.el
@@ -364,6 +364,17 @@ When non-nill, swap the tor-switch in prefix-arg effect."
(write-file file-name)))
(message "Wrote %s." file-name))
+;; Example url rewrite function
+(defun luwak-rewrite-ddg-result (url)
+ "Rewrites ddg result url to save one jump."
+ (let ((new-url url))
+ (when (string-match
+ "^https://duckduckgo.com/l/\\?uddg=\\(.*\\)&rut=.*$" url)
+ (setq new-url (url-unhex-string (match-string 1 url))))
+ (unless (equal url new-url)
+ (message "Rewriting %s to %s" url new-url))
+ new-url))
+
(provide 'luwak)
;;; luwak.el ends here