Skip to content

Commit 05f43e5

Browse files
improve script amount
1 parent ce68d48 commit 05f43e5

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

assets/api.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import hljs from "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/es/highlight.min.js";
2+
import json from "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/es/languages/json.min.js";
3+
4+
hljs.registerLanguage("json", json);
5+
16
async function loadExampleResponses() {
27
const servicesElement = document.getElementById("exampleServicesResponse");
38
const pingResponseElement = document.getElementById("examplePingResponse");
@@ -20,3 +25,5 @@ async function loadExampleResponses() {
2025
hljs.highlightElement(servicesElement);
2126
});
2227
}
28+
29+
loadExampleResponses().then(() => {});

assets/api/index.html

+5-8
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,19 @@ <h1>MCping API</h1>
3333
<p>
3434
The MCping API is very simple. There is a Java API at /api/java/, and a
3535
bedrock api at /api/bedrock/. To specify what server to ping, you append
36-
that server to the end of the URL, like so.
36+
that server to the end of the URL, like so:
37+
<a href="/api/java/mcping.me">/api/java/mcping.me</a>.
3738
</p>
38-
<a href="/api/java/mcping.me">/api/java/mcping.me</a>
39-
<br />
4039
<p>
41-
The response will look like so, with an "icon" base64 PNG field added if
42-
the server has an icon. The latency is in mlliseconds, from Toronto,
40+
The response will look as below, with an "icon" base64 PNG field added if
41+
the server has an icon. The latency is in milliseconds, from Toronto,
4342
Canada. Keep in mind that some servers may use signcode colors for the
4443
MOTD and player sample. Your application should handle this. The player
4544
sample is often used for advertising, so take it with a grain of salt. The
4645
Bedrock API response is the same, with the caveat of never returning the
4746
icon. The bedrock player list may also be synthetic.
4847
</p>
4948
<pre><code id="examplePingResponse" class="language-json"></code></pre>
50-
<br />
5149
<p>
5250
There is also a Mojang Services API, at
5351
<a href="/api/services">/api/services</a>. This is useful for checking if
@@ -57,7 +55,6 @@ <h1>MCping API</h1>
5755
<code>Operational</code>.
5856
</p>
5957
<pre><code id="exampleServicesResponse" class="language-json"></code></pre>
60-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
61-
<script src="/api.js"></script>
58+
<script src="/api.js" type="module"></script>
6259
</body>
6360
</html>

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static CSP_VALUE: HeaderValue = HeaderValue::from_static(
9090
connect-src 'self' https://*.giveip.io; \
9191
script-src 'self' https://cdnjs.cloudflare.com/ajax/libs/highlight.js/ \
9292
https://static.cloudflareinsights.com; \
93-
style-src 'self'; \
93+
style-src 'self' https://cdnjs.cloudflare.com/ajax/libs/highlight.js/; \
9494
object-src 'none'; \
9595
base-uri 'none'; \
9696
require-trusted-types-for 'script';",

0 commit comments

Comments
 (0)