|
|
| 第1行: |
第1行: |
| {{沙盒}} | | {{沙盒}} |
| <span id="glitch-text">简中Robloxian Wiki</span>
| |
|
| |
| <script type="text/javascript">
| |
| $(function() {
| |
| const element = document.getElementById('glitch-text');
| |
| const originalText = element.textContent;
| |
| const chars = '!@#$%^&*()_+-=[]{}|;:,.<>?/~`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
| |
| let interval;
| |
|
| |
| function glitch() {
| |
| let iteration = 0;
| |
| clearInterval(interval);
| |
|
| |
| interval = setInterval(() => {
| |
| element.textContent = originalText
| |
| .split('')
| |
| .map((char, index) => {
| |
| if (index < iteration) {
| |
| return originalText[index];
| |
| }
| |
| return chars[Math.floor(Math.random() * chars.length)];
| |
| })
| |
| .join('');
| |
|
| |
| if (iteration >= originalText.length) {
| |
| clearInterval(interval);
| |
| // 2秒后再次触发乱码
| |
| setTimeout(glitch, 2000);
| |
| }
| |
|
| |
| iteration += 1 / 3;
| |
| }, 30);
| |
| }
| |
|
| |
| // 页面加载完成后开始
| |
| glitch();
| |
| });
| |
| </script>
| |