Create a button to add the module to the install list.
import projects from "./composerProjects";
const addModules = new Map();
/**
* Process all project teaser titles.
*/
export default function addModuleButton() {
document.querySelectorAll('.node-project-module.node-teaser > h2 a')
.forEach(addButton);
}
/**
* Add button if not in existing projects list.
*
* @param {HTMLLinkElement} link
*/
function addButton(link) {
const title = link.parentElement;
if (!title.classList.contains('processed')) {
title.classList.add('processed');
const button = document.createElement('button');
button.innerText = 'Add';
const module = getModuleFromLink(link);
if (!addModules.has(module)) {
button.addEventListener('click', addToList);
title.appendChild(button);
}
}
}
Topics