微件:Extract collapsed navbox list

草awa留言 | 贡献2024年4月18日 (四) 18:11的版本
<script>
const elements = document.getElementsByClassName('collapsed-navbox-list-base');
const lists = document.getElementsByClassName('collapsed-navbox-list');
const extracters = document.getElementsByClassName('collapsed-navbox-list-extracter');
const unprocessed = document.getElementsByClassName('unprocessed-collapsed-navbox-list');

if (elements.length !== 0) {
    function extract(element, index, array) {
    	let styles = getComputedStyle(element);
        if (styles.display !== 'hidden' && styles.display !== 'none' ) {
            const list = lists[index];
            const extracter = extracters[index];
            const cloned = extracter.cloneNode(true);
            list.appendChild(cloned);
            extracter.remove();
            const unprocessedCollapsed = unprocessed[index];
            const clonedCollapsed = unprocessedCollapsed.cloneNode(true);
            clonedCollapsed.classList.remove('unprocessed-collapsed-navbox-list')
            unprocessedCollapsed.parentNode.appendChild(clonedCollapsed);
            unprocessedCollapsed.parentNode.removeChild(unprocessedCollapsed);
        } else {
        	element.remove();
        }
    }
    
	Array.from(elements).forEach(extract);
}
</script>