Last active
February 12, 2017 13:01
-
-
Save pacochi/dc32751856514ec4bf40d44e6abf2050 to your computer and use it in GitHub Desktop.
はてなブログで q 要素の cite 属性を展開します。
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
/* | |
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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
はてなブログの 設定>詳細設定>head に要素を追加 あたりに下記をコピペするとはてなダイアリーっぽく展開するようになります。