Created
June 11, 2023 16:57
-
-
Save lilianalillyy/6ca0b3b36a9fb62aec869bf9793ac90e to your computer and use it in GitHub Desktop.
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
const map = new Map(); | |
const directory = document.querySelector(".directory"); | |
const container = document.createElement("div"); | |
let currentIndex = -1; | |
const getNext = () => { currentIndex++; return map.get(currentIndex)?.href ?? null; } | |
directory.prepend(container); | |
Array.from(document.querySelectorAll(".filename")).map(f => f.innerText).forEach((q, i) => { | |
const a = document.createElement("a"); | |
a.classList.add("file") | |
a.href = `https://google.com/search?q=${q}`; | |
a.innerHTML = `<span class='filename'>${q}</span>` | |
container.append(a); | |
a.setAttribute("target", "_blank"); | |
map.set(i, a) | |
}) | |
const btn = document.createElement("a"); | |
btn.innerHTML = "Search next mod"; | |
btn.classList.add("btn", "btn-main"); | |
btn.href = getNext(); | |
btn.addEventListener("click", () => { const next = getNext(); next ? (btn.href = next) : btn.remove() }) | |
directory.prepend(btn); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment