From 37259fed83d1eedbcfd1ede0190de7e202a4bcfe Mon Sep 17 00:00:00 2001 From: Izumiko Date: Sat, 17 Feb 2024 14:24:54 +0000 Subject: [PATCH] deploy: 81c9a7d3ad763f760980862d2e74b19a8b3dae4e --- ede.user.js | 66 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/ede.user.js b/ede.user.js index 507a8d6..55e6aed 100644 --- a/ede.user.js +++ b/ede.user.js @@ -156,44 +156,54 @@ id: 'danmakuSettings', class: settings_icon, onclick: () => { - let opacityStr = prompt("请输入0-1之间的透明度值(如0.7)", window.ede.opacity || 0.7); - let speedStr = prompt("请输入0-1000弹幕速度(如200)", window.ede.speed || 200); - let sizeStr = prompt("请输入1-30弹幕大小(如18)", window.ede.fontSize || 18); - let heightRatio = prompt("请输入0-1之间的弹幕高度屏幕占比(如0.7)", window.ede.heightRatio || 0.7) - let tmpFiltersender = prompt("请输入需要过滤的弹幕来源(如bgdo)", window.ede.danmakufilter || '00') - if (window.ede) { + const modal = document.createElement('div'); + modal.innerHTML = ` +
+
+ + + + + +
+
+ + +
+
`; + document.body.appendChild(modal); + + modal.addEventListener('keydown', event => event.stopPropagation(), true); + + const closeModal = () => { + document.body.removeChild(modal); + modal.removeEventListener('keydown', event => event.stopPropagation(), true); + }; + + document.getElementById('saveSettings').onclick = () => { try { - let tmpOpacity = parseFloatOfRange(opacityStr, 0, 1); - let tmpSpeed = parseFloatOfRange(speedStr, 0, 1000); - let tmpSize = parseFloatOfRange(sizeStr, 1, 30); - let tmpHeightRatio = parseFloatOfRange(heightRatio, 0, 1); - // 设置透明度 - window.ede.opacity = tmpOpacity; - showDebugInfo(`设置弹幕透明度:${window.ede.opacity}`); + window.ede.opacity = parseFloatOfRange(document.getElementById('opacity').value, 0, 1); window.localStorage.setItem('danmakuopacity', window.ede.opacity.toString()); - // 设置弹幕速度 - window.ede.speed = tmpSpeed; - showDebugInfo(`设置弹幕速度:${window.ede.speed}`); + showDebugInfo(`设置弹幕透明度:${window.ede.opacity}`); + window.ede.speed = parseFloatOfRange(document.getElementById('speed').value, 0, 1000); window.localStorage.setItem('danmakuspeed', window.ede.speed.toString()); - // 设置弹幕大小 - window.ede.fontSize = tmpSize; - showDebugInfo(`设置弹幕大小:${window.ede.fontSize}`); + showDebugInfo(`设置弹幕速度:${window.ede.speed}`); + window.ede.fontSize = parseFloatOfRange(document.getElementById('fontSize').value, 1, 30); window.localStorage.setItem('danmakusize', window.ede.fontSize.toString()); - // 设置弹幕高度 - window.ede.heightRatio = tmpHeightRatio; - showDebugInfo(`设置弹幕高度:${window.ede.heightRatio}`); + showDebugInfo(`设置弹幕大小:${window.ede.fontSize}`); + window.ede.heightRatio = parseFloatOfRange(document.getElementById('heightRatio').value, 0, 1); window.localStorage.setItem('danmakuheight', window.ede.heightRatio.toString()); - //设置弹幕过滤 - window.ede.danmakufilter = tmpFiltersender.replace(/[^a-zA-Z0-9]/g, '').toUpperCase(); - showDebugInfo(`设置弹幕过滤:${window.ede.danmakufilter}`); + showDebugInfo(`设置弹幕高度:${window.ede.heightRatio}`); + window.ede.danmakufilter = document.getElementById('danmakufilter').value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase(); window.localStorage.setItem('danmakufilter', window.ede.danmakufilter); - //Reload reloadDanmaku('reload'); + showDebugInfo(`设置弹幕过滤:${window.ede.danmakufilter}`); + document.body.removeChild(modal); } catch (e) { alert(`Invalid input: ${e.message}`); - showDebugInfo(e); } - } + }; + document.getElementById('cancelSettings').onclick = closeModal; } };