<script>
const elements = document.getElementsByClassName('external_demand_span');
if (element.length == 0) {
const externalDemandShell = document.getElementById('external_demand_shell');
externalDemandShell.style.display = 'none';
return;
}
const appendTo = document.getElementById('external_demand');
const cats = new Map();
for (let i = 0; i < elements.length; i++) {
const element = elements[i];
const clone = element.cloneNode(true);
console.log(clone.title);
if (!cats.has(clone.title)) {
cats.set(clone.title,new Array());
}
cats.get(clone.title).push(clone);
clone.style.display = 'inline';
clone.classList.remove('external_demand_span')
}
console.log(cats);
function handler(value, key, map) {
console.log(key);
console.log(value);
const p = document.createElement('p');
p.innerText = '来自' + key + '的:';
appendTo.appendChild(p);
const ul = document.createElement('ul');
value.forEach((s) => {
const li = document.createElement('li');
li.appendChild(s);
ul.appendChild(li);
})
appendTo.appendChild(ul);
}
cats.forEach(handler);
</script>