|
9328 | 9328 | importBtn.style.fontSize = "20px"; |
9329 | 9329 | importBtn.addEventListener("click", e => { |
9330 | 9330 | let parentNode = importBtn.parentNode; |
9331 | | - if (!parentNode) return; |
| 9331 | + if (!parentNode || !e.isTrusted) return; |
9332 | 9332 | parentNode.removeChild(importBtn); |
9333 | 9333 | try { |
9334 | 9334 | let rules = parentNode.innerText.trim(); |
|
9522 | 9522 | padding: 0!important; |
9523 | 9523 | } |
9524 | 9524 | #saveBtn { |
9525 | | - width: 60vw; |
| 9525 | + width: var(--config-width, 60vw); |
9526 | 9526 | position: fixed; |
9527 | 9527 | z-index: 999; |
9528 | 9528 | bottom: 0; |
9529 | | - left: 20vw; |
| 9529 | + left: var(--config-left, 20vw); |
9530 | 9530 | font-size: xx-large; |
9531 | 9531 | opacity: 0.6; |
9532 | 9532 | cursor: pointer; |
|
10021 | 10021 | } |
10022 | 10022 |
|
10023 | 10023 | updateP.onclick = e => { |
| 10024 | + if (!e.isTrusted) return; |
10024 | 10025 | updateFail = false; |
10025 | 10026 | //ruleParser.rules = []; |
10026 | 10027 | showTips(i18n("beginUpdate"), "", 30000); |
|
10105 | 10106 | saveBtn.innerHTML = i18n("save"); |
10106 | 10107 | saveBtn.id = "saveBtn"; |
10107 | 10108 | configCon.appendChild(saveBtn); |
| 10109 | + saveBtn.style.display = "none"; |
| 10110 | + const syncSaveBtnLayout = () => { |
| 10111 | + if (!configCon || !saveBtn) return; |
| 10112 | + const rect = configCon.getBoundingClientRect(); |
| 10113 | + if (rect.width > 0) { |
| 10114 | + document.documentElement.style.setProperty("--config-left", `${rect.left}px`); |
| 10115 | + document.documentElement.style.setProperty("--config-width", `${rect.width}px`); |
| 10116 | + saveBtn.style.display = ""; |
| 10117 | + } else { |
| 10118 | + saveBtn.style.display = "none"; |
| 10119 | + } |
| 10120 | + }; |
| 10121 | + syncSaveBtnLayout(); |
| 10122 | + window.addEventListener("resize", syncSaveBtnLayout); |
| 10123 | + if (window.ResizeObserver) { |
| 10124 | + const saveBtnResizeObserver = new ResizeObserver(() => { |
| 10125 | + syncSaveBtnLayout(); |
| 10126 | + }); |
| 10127 | + saveBtnResizeObserver.observe(configCon); |
| 10128 | + } |
10108 | 10129 | saveBtn.onclick = e => { |
10109 | 10130 | try { |
| 10131 | + if (!e.isTrusted) return; |
10110 | 10132 | let customRules; |
10111 | 10133 | if (editor) { |
10112 | 10134 | if (editorChanged) { |
|
0 commit comments