Skip to content

Instantly share code, notes, and snippets.

@gongo
Last active July 26, 2019 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gongo/2f01279939b49be353b90bf56e657c36 to your computer and use it in GitHub Desktop.
Save gongo/2f01279939b49be353b90bf56e657c36 to your computer and use it in GitHub Desktop.
eww (Emacs Web ブラウザ) でアクセスしたページの、はてなブックマークコメントをニコニコ動画っぽく表示してくれるやつ https://twitter.com/gongoZ/status/1154568260139941888
(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)
@gongo
Copy link
Author

gongo commented Jul 26, 2019

未完成なので、奇跡的に動いています

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