Last active
February 22, 2023 01:56
-
-
Save hzhangxyz/0f8da48527b6e357d0487bc128d3f2af to your computer and use it in GitHub Desktop.
Show all image in a single folder
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
<div id=container /> | |
<script> | |
async function getList() { | |
const resp = await fetch("list.txt", {cache: "no-store"}) | |
const text = await resp.text() | |
const list = text.split("\n") | |
return list.filter(name => name.includes(".png")) | |
} | |
var container = document.getElementById("container") | |
var oldList = [] | |
function appendImage(name) { | |
if (!oldList.includes(name)) { | |
const image = document.createElement('img') | |
image.src = name | |
console.log("append " + name) | |
container.appendChild(image) | |
oldList.push(name) | |
} | |
} | |
setInterval(async function() { | |
const newList = await getList() | |
newList.forEach(appendImage) | |
},1000) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is useful when using this index.html