Skip to content

Commit

Permalink
deploy: 81c9a7d
Browse files Browse the repository at this point in the history
  • Loading branch information
Izumiko committed Feb 17, 2024
1 parent 41094b7 commit 37259fe
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions ede.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<div style="background: #f0f0f0; padding: 20px; border-radius: 5px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);">
<div style="display: flex; flex-direction: column; gap: 5px; color: #333;">
<label for="opacity">透明度 (0~1):</label><input type="number" id="opacity" min="0" max="1" step="0.1" value="${window.ede.opacity || 0.7}">
<label for="speed">弹幕速度 (0~1000):</label><input type="number" id="speed" min="0" max="1000" value="${window.ede.speed || 200}">
<label for="fontSize">字体大小 (1~30):</label><input type="number" id="fontSize" min="1" max="30" value="${window.ede.fontSize || 18}">
<label for="heightRatio">高度比例 (0~1):</label><input type="number" id="heightRatio" min="0" max="1" step="0.1" value="${window.ede.heightRatio || 0.7}">
<label for="danmakufilter">弹幕过滤:</label><input id="danmakufilter" value="${window.ede.danmakufilter || '00'}">
</div>
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
<button id="saveSettings">保存设置</button>
<button id="cancelSettings">取消</button>
</div>
</div>`;
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;
}
};

Expand Down

0 comments on commit 37259fe

Please sign in to comment.