()
| 87 | |
| 88 | // 添加更新全选按钮状态的函数 |
| 89 | function updateSelectAllButtonState() { |
| 90 | const selectAllBtn = document.getElementById('select-all'); |
| 91 | // 只获取当前可见的复选框 |
| 92 | const visibleCheckboxes = Array.from(document.querySelectorAll('.result-item')) |
| 93 | .filter(item => item.style.display !== 'none') |
| 94 | .map(item => item.querySelector('.bookmark-checkbox')); |
| 95 | |
| 96 | if (selectAllBtn && visibleCheckboxes.length > 0) { |
| 97 | const isAllSelected = visibleCheckboxes.every(cb => cb.checked); |
| 98 | |
| 99 | let span = selectAllBtn.querySelector('span[data-i18n]'); |
| 100 | |
| 101 | if (!span) { |
| 102 | span = document.createElement('span'); |
| 103 | span.setAttribute('data-i18n', 'selectAll'); |
| 104 | selectAllBtn.textContent = ''; |
| 105 | selectAllBtn.appendChild(span); |
| 106 | } |
| 107 | |
| 108 | const messageKey = isAllSelected ? 'deselectAll' : 'selectAll'; |
| 109 | span.setAttribute('data-i18n', messageKey); |
| 110 | span.textContent = chrome.i18n.getMessage(messageKey); |
| 111 | |
| 112 | // 只有当有可见项目时才启用按钮 |
| 113 | selectAllBtn.disabled = visibleCheckboxes.length === 0; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // 添加更新删除按钮状态的函数 |
| 118 | function updateDeleteButtonState() { |
no outgoing calls
no test coverage detected