Original link: https://yzyyz.top/archives/js_snake.html

Thanks to Platane/snk , such a picture was generated in my Github repository

(It was accelerated using staticaly due to force majeure)
With such an image, you can use JS to add it to the blog homepage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 twenty one twenty two twenty three twenty four 25 26 27 28 29 30 31
|
// 2022/9/2 // add_snake.js // Author: Kindergarten Principal // 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>" insertAfter(newDiv, div)
function insertAfter ( newElement, targetElement ) { "use strict" ; let parent = targetElement.parentNode; if (parent.lastChild === targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); } }
let width = window.screen.width if (width < 580 ) { let postDiv = document .getElementsByClassName( "l_body" )[ 0 ] postDiv.style.margin = "0 auto" } } }
|
This article is reprinted from: https://yzyyz.top/archives/js_snake.html
This site is for inclusion only, and the copyright belongs to the original author.