微件:Extract collapsed navbox list:修订间差异
跳转到导航
跳转到搜索
删除的内容 添加的内容
小无编辑摘要 |
小无编辑摘要 |
||
第3行: | 第3行: | ||
const lists = document.getElementsByClassName('collapsed-navbox-list'); |
const lists = document.getElementsByClassName('collapsed-navbox-list'); |
||
const extracters = document.getElementsByClassName('collapsed-navbox-list-extracter'); |
const extracters = document.getElementsByClassName('collapsed-navbox-list-extracter'); |
||
const unprocessed = document.getElementsByClassName('unprocessed-collapsed-navbox-list'); |
|||
if (elements.length !== 0) { |
if (elements.length !== 0) { |
||
第13行: | 第14行: | ||
list.appendChild(cloned); |
list.appendChild(cloned); |
||
extracter.remove(); |
extracter.remove(); |
||
unprocessed.classList.remove('unprocessed-collapsed-navbox-list') |
|||
} else { |
} else { |
||
element.remove(); |
element.remove(); |
2024年4月18日 (四) 18:07的版本
<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();
unprocessed.classList.remove('unprocessed-collapsed-navbox-list')
} else {
element.remove();
}
}
Array.from(elements).forEach(extract);
}
</script>