Skip to content

Instantly share code, notes, and snippets.

Last active July 26, 2019 01:46
What would you like to do?
eww (Emacs Web ブラウザ) でアクセスしたページの、はてなブックマークコメントをニコニコ動画っぽく表示してくれるやつ
(require 'deferred)
(require 'request-deferred)
(require 'eww)
(defun eww-hatebu-nicomment ()
(let ((url (url-hexify-string (eww-current-url))))
(request-deferred (concat "" url)
:type "GET"
:parser 'json-read)
(deferred:nextc it
(lambda (res)
(request-response-data res)))
(deferred:nextc it
(lambda (res)
(cdr (assoc 'bookmarks res))))
(deferred:nextc it
(lambda (comments)
(loop for c across-ref comments
when (< 0 (length (cdr (assoc 'comment c))))
collect c)))
(deferred:nextc it
(lambda (comments)
(let ((i 1))
(when nicomment-mode
(dolist (c comments)
(add-comment c i)
(incf i 0.4))))))
(defun add-comment (c i)
(lexical-let ((comment (cdr (assoc 'comment c)) ))
(run-at-time i nil (lambda () (nicomment-add-comment comment :size 'small)))))
(add-hook 'eww-after-render-hook #'eww-hatebu-nicomment)
Copy link

gongo commented Jul 26, 2019


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment