Skip to content

Instantly share code, notes, and snippets.

@pacochi
Last active February 12, 2017 13:01
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 pacochi/dc32751856514ec4bf40d44e6abf2050 to your computer and use it in GitHub Desktop.
Save pacochi/dc32751856514ec4bf40d44e6abf2050 to your computer and use it in GitHub Desktop.
はてなブログで q 要素の cite 属性を展開します。
/*
http://hatenadiary.g.hatena.ne.jp/keyword/%E5%BC%95%E7%94%A8%E5%85%83%E3%82%B5%E3%82%A4%E3%83%88%E3%82%92%E8%87%AA%E5%8B%95%E7%9A%84%E3%81%AB%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B%EF%BC%88cite%E3%80%81title%E5%B1%9E%E6%80%A7%EF%BC%89
q の cite がはてなブログで展開されないので書きました。
*/
document.addEventListener('DOMContentLoaded', function() {
Array.prototype.forEach.call(document.querySelectorAll('q[cite]'), function(node) {
var cite = document.createElement('cite');
var a = document.createElement('a');
a.setAttribute('href', node.getAttribute('cite'));
a.appendChild(document.createTextNode(node.getAttribute('title') || '*'));
cite.appendChild(a);
node.appendChild(cite);
});
});
@pacochi
Copy link
Author

pacochi commented May 18, 2016

はてなブログの 設定>詳細設定>head に要素を追加 あたりに下記をコピペするとはてなダイアリーっぽく展開するようになります。

<script type="text/javascript" src="https://cdn.rawgit.com/pacochi/dc32751856514ec4bf40d44e6abf2050/raw/hatenablog_q_cite_expander.js"></script>

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