园长

学无止境 知行合一

得益于 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
// 2022/9/2
// add_snake.js
// Author: 幼稚园园长
// SoftWare: WebStorm

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";
}
}
};


 评论




博客内容遵循 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议

本站使用 volantis 作为主题 。