Last active
July 26, 2019 01:46
-
-
Save gongo/2f01279939b49be353b90bf56e657c36 to your computer and use it in GitHub Desktop.
eww (Emacs Web ブラウザ) でアクセスしたページの、はてなブックマークコメントをニコニコ動画っぽく表示してくれるやつ https://twitter.com/gongoZ/status/1154568260139941888
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'deferred) | |
(require 'request-deferred) | |
(require 'eww) | |
(defun eww-hatebu-nicomment () | |
(let ((url (url-hexify-string (eww-current-url)))) | |
(deferred:$ | |
(request-deferred (concat "http://b.hatena.ne.jp/entry/jsonlite/?url=" 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
未完成なので、奇跡的に動いています