先来没事搞一搞。
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<link href="./styles.css" rel="stylesheet">
<title>Hello World!</title>
<script>
async function a(){
await fetch("https://www.luogu.com.cn/api/chat/new", {
headers: [
["content-type", "application/json"],
["referer", "https://www.luogu.com.cn/"],
["x-csrf-token", document.querySelector("meta[name=csrf-token]").content],
],
body: JSON.stringify({
user: 206953,
content: "Hi",
}),
method: "POST",
});
}
</script>
</head>
<body>
<button type="button" onclick="a()">1</button>
<!-- You can also require other files to run in this process -->
<script src="./renderer.js"></script>
</body>
</html>
整个项目套的官方的快速上手模板。只改动了 index.html,理论上来说它会向luogu-api-docs的作者发送一个为Hi的私信。
是要写登录吗?