Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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
You can’t perform that action at this time.