[nyxt] Add function that redirects some URLs to free alternatives
This commit is contained in:
parent
adda08ef4a
commit
56978223eb
1 changed files with 65 additions and 6 deletions
|
@ -5,16 +5,75 @@ Always restore the previous session when the browser starts.
|
||||||
((session-restore-prompt :always-restore)))
|
((session-restore-prompt :always-restore)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Add a function that automatically redirects certain URLs to free alternatives.
|
||||||
|
|
||||||
|
#+begin_src lisp
|
||||||
|
(defun init-redirect-to-alternative (request-data)
|
||||||
|
(labels ((log-uri (uri)
|
||||||
|
(log:info "Switching to URL: ~a://~a~a"
|
||||||
|
(quri:uri-scheme uri)
|
||||||
|
(quri:uri-host uri)
|
||||||
|
(quri:uri-path uri))))
|
||||||
|
(let* ((uri (url request-data))
|
||||||
|
(host (quri:uri-host uri)))
|
||||||
|
(cond
|
||||||
|
((search "blog.bitsrc.io" host)
|
||||||
|
(setf (url request-data)
|
||||||
|
(progn
|
||||||
|
(setf (quri:uri-host uri) "scribe.rip"
|
||||||
|
(quri:uri-path uri) (concatenate 'string "/bitsrc" (quri:uri-path uri)))
|
||||||
|
(log-uri uri)
|
||||||
|
uri)))
|
||||||
|
((search "levelup.gitconnected.com" host)
|
||||||
|
(setf (url request-data)
|
||||||
|
(progn
|
||||||
|
(setf (quri:uri-host uri) "scribe.rip"
|
||||||
|
(quri:uri-path uri) (concatenate 'string "/gitconnected" (quri:uri-path uri)))
|
||||||
|
(log-uri uri)
|
||||||
|
uri)))
|
||||||
|
((or (search "kevingosse.medium.com" host)
|
||||||
|
(search "minidump.net" host))
|
||||||
|
(setf (url request-data)
|
||||||
|
(progn
|
||||||
|
(setf (quri:uri-host uri) "scribe.rip"
|
||||||
|
(quri:uri-path uri) (concatenate 'string "/kevingosse" (quri:uri-path uri)))
|
||||||
|
(log-uri uri)
|
||||||
|
uri)))
|
||||||
|
((search "medium.com" host :end2 (length "medium.com"))
|
||||||
|
(setf (url request-data)
|
||||||
|
(progn
|
||||||
|
(setf (quri:uri-host uri) "scribe.rip")
|
||||||
|
(log-uri uri)
|
||||||
|
uri)))
|
||||||
|
((search "twitter.com" host)
|
||||||
|
(setf (url request-data)
|
||||||
|
(progn
|
||||||
|
(setf (quri:uri-host uri) "nitter.net")
|
||||||
|
(log-uri uri)
|
||||||
|
uri)))
|
||||||
|
((search "www.youtube.com" host)
|
||||||
|
(setf (url request-data)
|
||||||
|
(progn
|
||||||
|
(setf (quri:uri-host uri) "redirect.invidious.io")
|
||||||
|
(log-uri uri)
|
||||||
|
uri))))))
|
||||||
|
request-data)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
I want the keys to function more like Emacs, so I enable =emacs-mode= for all buffers. I also want my downloads to go to =~/downloads= instead of =~/Downloads=.
|
I want the keys to function more like Emacs, so I enable =emacs-mode= for all buffers. I also want my downloads to go to =~/downloads= instead of =~/Downloads=.
|
||||||
|
|
||||||
#+begin_src lisp
|
#+begin_src lisp
|
||||||
(define-configuration buffer
|
(define-configuration buffer
|
||||||
((default-modes (append '(emacs-mode) %slot-default%))
|
((default-modes (append '(emacs-mode) %slot-default%))
|
||||||
(download-path (make-instance 'data-path :dirname "~/downloads"))
|
(download-path (make-instance 'data-path :dirname "~/downloads"))
|
||||||
;; Bind org-capture to `C-c o c', but only in emacs-mode.
|
(request-resource-hook
|
||||||
(override-map
|
(reduce #'hooks:add-hook
|
||||||
(let ((map (make-keymap "override-map")))
|
(mapcar #'make-handler-resource (list #'init-redirect-to-alternative))
|
||||||
(define-key map "C-c o c" 'org-capture)))))
|
:initial-value %slot-default%))
|
||||||
|
;; Bind org-capture to `C-c o c', but only in emacs-mode.
|
||||||
|
(override-map
|
||||||
|
(let ((map (make-keymap "override-map")))
|
||||||
|
(define-key map "C-c o c" 'org-capture)))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Set up capturing URLs with org-capture in Emacs. From https://ag91.github.io/blog/2021/07/09/org-capture-in-nyxt-taking-notes-while-browsing/.
|
Set up capturing URLs with org-capture in Emacs. From https://ag91.github.io/blog/2021/07/09/org-capture-in-nyxt-taking-notes-while-browsing/.
|
||||||
|
|
Loading…
Reference in a new issue