From d6897a634a68e8206162b4dcc8c43ea006a86e39 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 1 Apr 2022 18:44:23 -0700 Subject: [oni-browse] Redirect any ‘*.medium.com’ URL to scribe.rip --- oni-browse-url.el | 76 +++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/oni-browse-url.el b/oni-browse-url.el index 8a6cee9..7bd702e 100644 --- a/oni-browse-url.el +++ b/oni-browse-url.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2022.0228.012441 +;; Version: 2022.0311.230935 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -34,47 +34,39 @@ "Check the url given to ‘browse-url’ and redirect to a free alternative if available. ARGS is the list of arguments that was passed to ‘browse-url’ before this filter." - (cond - ((string-prefix-p "https://blog.bitsrc.io" (car args)) - (cons (string-replace "https://blog.bitsrc.io" "https://scribe.rip/bitsrc" (car args)) - (cdr args))) - ((string-prefix-p "https://levelup.gitconnected.com" (car args)) - (cons (string-replace "https://levelup.gitconnected.com" "https://scribe.rip/gitconnected" (car args)) - (cdr args))) - ((string-prefix-p "https://twitter.com" (car args)) - (cons (string-replace "https://twitter.com" "https://nitter.net" (car args)) - (cdr args))) - ((string-prefix-p "https://kevingosse.medium.com" (car args)) - (cons (string-replace "https://kevingosse.medium.com" "https://scribe.rip/kevingosse" (car args)) - (cdr args))) - ((string-prefix-p "https://medium.marqeta.com" (car args)) - (cons (string-replace "https://medium.marqeta.com" "https://scribe.rip/marqeta" (car args)) - (cdr args))) - ((string-prefix-p "https://kevlinhenney.medium.com" (car args)) - (cons (string-replace "https://kevlinhenney.medium.com" "https://scribe.rip" (car args)) - (cdr args))) - ((string-prefix-p "https://upekabee.medium.com" (car args)) - (cons (string-replace "https://upekabee.medium.com" "https://scribe.rip" (car args)) - (cdr args))) - ((string-prefix-p "https://itnext.io" (car args)) - (cons (string-replace "https://itnext.io" "https://scribe.rip" (car args)) - (cdr args))) - ((string-prefix-p "https://medium.com" (car args)) - (cons (string-replace "https://medium.com" "https://scribe.rip" (car args)) - (cdr args))) - ((string-prefix-p "https://www.youtube.com" (car args)) - (cons (string-replace "https://www.youtube.com" "https://yewtu.be" (car args)) - (cdr args))) - ((string-prefix-p "https://m.youtube.com" (car args)) - (cons (string-replace "https://m.youtube.com" "https://yewtu.be" (car args)) - (cdr args))) - ((string-prefix-p "https://youtu.be" (car args)) - (cons (string-replace "https://youtu.be/" "https://yewtu.be/watch?v=" (car args)) - (cdr args))) - ((string-prefix-p "https://www.instagram.com" (car args)) - (cons (string-replace "https://www.instagram.com" "https://bibliogram.1d4.us/u" (car args)) - (cdr args))) - (t args))) + (save-match-data + (cond + ((string-prefix-p "https://blog.bitsrc.io" (car args)) + (cons (string-replace "https://blog.bitsrc.io" "https://scribe.rip/bitsrc" (car args)) + (cdr args))) + ((string-prefix-p "https://levelup.gitconnected.com" (car args)) + (cons (string-replace "https://levelup.gitconnected.com" "https://scribe.rip/gitconnected" (car args)) + (cdr args))) + ((string-prefix-p "https://twitter.com" (car args)) + (cons (string-replace "https://twitter.com" "https://nitter.net" (car args)) + (cdr args))) + ((string-prefix-p "https://medium.marqeta.com" (car args)) + (cons (string-replace "https://medium.marqeta.com" "https://scribe.rip/marqeta" (car args)) + (cdr args))) + ((string-prefix-p "https://itnext.io" (car args)) + (cons (string-replace "https://itnext.io" "https://scribe.rip" (car args)) + (cdr args))) + ((string-match (rx "https://" (optional (one-or-more (not ".")) ".") "medium.com") (car args)) + (cons (replace-match "https://scribe.rip" nil nil (car args)) + (cdr args))) + ((string-prefix-p "https://www.youtube.com" (car args)) + (cons (string-replace "https://www.youtube.com" "https://yewtu.be" (car args)) + (cdr args))) + ((string-prefix-p "https://m.youtube.com" (car args)) + (cons (string-replace "https://m.youtube.com" "https://yewtu.be" (car args)) + (cdr args))) + ((string-prefix-p "https://youtu.be" (car args)) + (cons (string-replace "https://youtu.be/" "https://yewtu.be/watch?v=" (car args)) + (cdr args))) + ((string-prefix-p "https://www.instagram.com" (car args)) + (cons (string-replace "https://www.instagram.com" "https://bibliogram.1d4.us/u" (car args)) + (cdr args))) + (t args)))) (setq browse-url-browser-function (if (eql system-type 'windows-nt) -- cgit v1.2.3-54-g00ecf