得益于 Platane/snk,在我的Github仓库就生成了这样一张图片
(由于不可抗力原因,使用了staticaly对其进行了加速)
有了这样一张图片,便可以使用JS将其添加在博客首页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
window.onload = function () { if (window.location.pathname === '/') { let div = document.getElementsByClassName("cover-wrapper")[0]; let newDiv = document.createElement("div"); newDiv.className = "snake"; newDiv.style.marginTop = "110px"; newDiv.innerHTML = "<a href='https://github.com/yzyyz1387/' target='_blank'><img src=\"https://cdn.staticaly.com/gh/yzyyz1387/yzyyz1387/main/assets/github-contribution-grid-snake.svg\" alt=\"\" style=\"display: block; margin: 0 auto;background: #fff;\"></a>"; div.insertAdjacentElement("afterend", newDiv); let width = window.screen.width; if (width < 580) { let postDiv = document.getElementsByClassName("l_body")[0]; postDiv.style.margin = "0 auto"; } } };
|