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> | |
var newDomain = "https://www.moyashidaisuke.com"; // 新URL | |
var replacedStr; | |
var path = location.pathname; | |
if(path.startsWith('\/entry')){ //記事ページの時 | |
// pathを/区切りで分解 | |
var ary = path.split('/'); | |
// 最後のブロックをidとして使う | |
replacedStr = '/' + ary[ary.length - 1]; | |
} else { | |
replacedStr = ''; | |
} | |
var url = newDomain + replacedStr; | |
// check | |
console.log(url); | |
var link = document.getElementsByTagName("link")[0]; | |
link.href = url; | |
setTimeout("redirect()", 0); // 0秒後にジャンプ | |
function redirect(){ | |
location.href = url; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment