From 9c95bcb74ffccbbc50a529dbbec81e24ddce6baf Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 21 Oct 2022 23:44:29 +1100 Subject: adding an example url rewrite function --- luwak.el | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 -- cgit v1.2.3