blob: 2d59c1fd969e23762e92b65d5fcdc0d493955c68 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<script>
async function fetchData() {
const API_URL = "https://api.lanyard.rest/v1/users/246787839570739211";
try {
const response = await fetch(API_URL);
const data = await response.json();
if (data && data.success) {
const activities = data.data.activities;
let activityHTML = "";
for (const activity of activities) {
const imageUrl =
activity.assets && activity.assets.large_image
? activity.assets.large_image
: "";
activityHTML += `
<div class="activity-card">
<h3>${activity.name}</h3>
<p>${activity.details ? activity.details : ""}</p>
<p>${activity.state ? activity.state : ""}</p>
</div>
`;
}
document.querySelector("#activities").innerHTML = activityHTML;
} else {
console.error("Failed fetching user data:", data.message);
}
} catch (error) {
console.error("Network error:", error);
}
}
window.addEventListener("DOMContentLoaded", fetchData);
</script>
<section>
<div>
<div id="activities"></div>
</div>
</section>
<style>
section {
max-width: 800px;
margin: 40px auto;
padding: 24px;
border-radius: 12px;
background-color: #1a1a1a;
font-family: 'Courier New', Courier, monospace;
color: #c0c0c0;
}
.activity-card {
background-color: #1a1a1a;
padding: 20px;
margin-bottom: 16px;
border: 1px solid #c0c0c0;
display: flex;
flex-direction: column;
}
.activity-card h3 {
margin-top: 0;
margin-bottom: 8px;
}
.activity-card p {
margin: 0;
font-size: 0.5em;
line-height: 1.5;
padding: 4px 0;
}
.activity-card p + p {
margin-top: 6px;
border-top: 1px dashed #c0c0c0;
padding-top: 8px;
}
</style>
|