From 02610a9b6a93c5716f6d69e6206f7c2673055e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=E5=B0=8F=E9=80=8F=E6=98=8E=E3=83=BB=E5=AE=B8?= =?UTF-8?q?=E2=9C=A8?= <47057319+TransparentLC@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E9=80=9A=E8=BF=87=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E6=97=A0=E5=A3=B0=E9=9F=B3=E9=A2=91=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=9C=A8=E5=90=8E=E5=8F=B0=E5=85=A8=E9=80=9F?= =?UTF-8?q?=E7=AE=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 - src/main.ts | 10 ++++++++++ src/near-silence.ogg | Bin 0 -> 736 bytes 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/near-silence.ogg diff --git a/index.html b/index.html index 1f71fc2..dd9a8a0 100644 --- a/index.html +++ b/index.html @@ -63,7 +63,6 @@
  • 某科学的 PGP 算号指南
  • 密钥使用 OpenPGP.js 在浏览器中生成,不会发送到其他地方。如果仍然担心这一点,可以检查源代码、查看浏览器开发者工具的“网络”部分、或在页面加载完成后断网使用。

    -

    注意:浏览器可能会限制在后台标签页中运行的内容,因此算号时请避免切换到其它标签页或将浏览器窗口最小化,否则会严重影响算号速度。作为替代,你可以将这个标签页拖出成为一个单独的窗口,使用各类工具将窗口置顶,然后拖到屏幕边缘。


    diff --git a/src/main.ts b/src/main.ts index 1d19b93..54de305 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import { } from 'openpgp/lightweight'; import { createVanityKey } from './vanity-key.ts'; import tadaData from './tada.ogg?inline'; +import silenceData from './near-silence.ogg?inline'; import { EllipticCurveName, GenerateKeyOptions, @@ -17,6 +18,13 @@ import 'terminal.css'; const tada = new Audio(tadaData); +// 通过播放音频阻止浏览器降低setTimeout的频率 +// 完全静音的音频是没有效果的…… +// ffmpeg -f lavfi -i "sine=frequency=1:duration=1" -c:a libopus -ar 8k -b:a 1k -movflags +faststart -fflags +bitexact -map_metadata -1 -dn near-silence.ogg +const silence = new Audio(silenceData); +silence.volume = .01; +silence.loop = true; + const app: { keyType: EllipticCurveName | '2048' | '3072' | '4096', userIDInput: UserID, @@ -131,6 +139,7 @@ const app: { this.hashCount = 0; this.runningTime = 0; this.running = true; + silence.play(); try { const options: GenerateKeyOptions = { userIDs: this.userID, @@ -189,6 +198,7 @@ const app: { alert(err); } finally { this.running = false; + silence.pause(); } }, diff --git a/src/near-silence.ogg b/src/near-silence.ogg new file mode 100644 index 0000000000000000000000000000000000000000..82a5874b8121fef4b01da8b160862108cebbad8a GIT binary patch literal 736 zcmeZIPY-5bVn72aJC9^B3i}t77JH;7rZ6&EFgnPCmH2~{qX0%A@AK&kw;9Di%0m*< zi`jr8X=%9ysp%kv5FHJ>L2L*B*|sf2#?FX~n~R$ph&j19xqyHN$mc<#xVX51LO>Cq z0*Ej-huHZS#(ldz3mrHtjkc>=pMEUWaf8D;>%pVeld;|s95&Vgj}jcx%*`7(Y!0Vx zd$q7?)eKDL+`H~GFytrBf52h0X6dK9&zu7ksp>(J2}rk#3MIILzBJn}u4+}yss0_^mnFMmTcIBb-DD>!Q%N>Tv3 zERy+EPSSCp)6bT7UcBr1tc$}|a_P2+*UR?9nnYDE*cA z><1S4M6V2p{Ojq_4#+H~x6i)4dMG;^7z#U1G?@Rf=W(4G!C}K0(jmS6Uy=cbwWP)a z33cJBGcUj)Az|oSn!84Y!(7Eu{e