Last active
December 16, 2017 07:30
-
-
Save seriwb/3617db79e9e0715d4b04 to your computer and use it in GitHub Desktop.
はてなブログのリンクを別ウインドウで開くようにするためのスクリプト。デザイン設定のヘッダに以下のHTMLを追加する。キーワードも別ウインドウで出したい場合は、11行目の条件を削除すること。
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
<script> | |
window.onload = function() | |
{ | |
var entry_contents = document.getElementsByClassName("entry-content"); | |
for (var i=0; i < entry_contents.length; i++) { | |
var links = entry_contents[i].getElementsByTagName("a"); | |
for (var j=0; j < links.length; j++) { | |
if (!links[j].getAttribute('href').startsWith('#') || ( | |
links[j].className !== "entry-see-more" && | |
links[j].className !== "keyword")) { | |
links[j].setAttribute("target", "_blank"); | |
} | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment