+168
-4
index.php
+168
-4
index.php
···
26
26
th, td {
27
27
padding: 15px;
28
28
}
29
+
30
+
#kibun {
31
+
}
29
32
</style>
30
33
</head>
31
34
32
35
<body>
33
-
<div style="margin: 0 auto; width: 75%; font-family: courier new; text-align: center; margin-top: 20%;">
36
+
<div style="margin: 0 auto; width: 75%; font-family: courier new; text-align: center; margin-top: 10%;">
34
37
<pre>
35
38
36
39
▄████ ▒█████ ██▀███ ▓█████ ▒███████▒ ▒█████ ███▄ █ ▓█████
···
44
47
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
45
48
░ ░
46
49
</pre>
47
-
<br><br>
48
-
<center><table style="font-size: 1.2em; font-family: courier new;"><tr style="padding: 15px;"><td>🦋 <a href="https://bsky.app/profile/tigerlily.cafe">bsky</a> <br>
50
+
51
+
<div id="kibun" data-username="tigerlily.cafe">
52
+
<script>function timeAgo (dateString) {
53
+
const date = Date.parse(dateString);
54
+
const curDate = new Date(date);
55
+
const now = Date.now();
56
+
const yest = new Date(Date.parse(dateString));
57
+
const today = new Date(date);
58
+
yest.setDate(today - 1);
59
+
const diff = (now - date) / 1000; // difference in seconds
60
+
if (diff < 5) {
61
+
return "just now";
62
+
} else if (diff < 60) {
63
+
return `${diff} seconds ago`;
64
+
} else if (diff < 60*60) {
65
+
const min = Math.floor(diff / 60);
66
+
return `${min} minute${min > 1 ? 's' : ''} ago`;
67
+
} else if (diff < 60*60*24) {
68
+
const hr = Math.floor(diff / (60*60));
69
+
return `${hr} hour${hr > 1 ? 's' : ''} ago`;
70
+
} else if (date.getDate() === yest.getDate() && date.getMonth() === yest.getMonth() && date.getYear() === yest.getYear()) {
71
+
return "yesterday";
72
+
}
73
+
return `${curDate.toLocaleDateString(undefined, {
74
+
weekday: 'short',
75
+
year: 'numeric',
76
+
month: 'short',
77
+
day: 'numeric'
78
+
}).toLowerCase()}`;
79
+
}
80
+
81
+
async function getLatest() {
82
+
const kibunBase = document.getElementById('kibun');
83
+
const username = kibunBase.getAttribute('data-username');
84
+
const userDidData = await fetch(`https://slingshot.microcosm.blue/xrpc/com.bad-example.identity.resolveMiniDoc?identifier=${username}`);
85
+
const userDidDoc = await userDidData.json();
86
+
const userDid = userDidDoc.did;
87
+
const userPds = userDidDoc.pds;
88
+
const userInfoReq = await fetch(`
89
+
${userPds}/xrpc/com.atproto.repo.getRecord?repo=${userDid}&collection=app.bsky.actor.profile&rkey=self`);
90
+
const userInfoData = await userInfoReq.json();
91
+
const displayName = userInfoData.value.displayName;
92
+
console.log(userInfoData);
93
+
const statusData = await fetch(`${userPds}/xrpc/com.atproto.repo.listRecords?repo=${userDid}&collection=social.kibun.status&limit=1`);
94
+
const statuses = await statusData.json();
95
+
if (statuses.records.length === 0) return;
96
+
const status = statuses.records[0];
97
+
const container = document.createElement('div');
98
+
container.id = 'kibun-container';
99
+
100
+
const header = document.createElement('div');
101
+
header.id = 'kibun-header';
102
+
103
+
const userLink = document.createElement('a');
104
+
userLink.href = `https://www.kibun.social/users/${username}`;
105
+
userLink.textContent = displayName;
106
+
userLink.id = 'kibun-displayname';
107
+
108
+
console.log(status.value.createdAt);
109
+
const parsedDate = Date.parse(status.value.createdAt);
110
+
const postTime = document.createElement('span');
111
+
postTime.textContent = timeAgo(status.value.createdAt);
112
+
postTime.id = 'kibun-datetime';
113
+
114
+
const emoji = status.value.emoji;
115
+
const emojiSign = document.createElement('span')
116
+
emojiSign.textContent = emoji;
117
+
emojiSign.id = 'kibun-emoji';
118
+
119
+
const userHandle = document.createElement('a');
120
+
userHandle.href = `https://kibun.social/users/${username}`;
121
+
userHandle.textContent = '@'+username;
122
+
userHandle.id = 'kibun-handle';
123
+
124
+
header.append(userLink);
125
+
header.append(emojiSign);
126
+
header.append(userHandle);
127
+
header.append(postTime);
128
+
container.append(header);
129
+
130
+
const statusText = document.createElement('div');
131
+
statusText.textContent = status.value.text;
132
+
statusText.id = 'kibun-status';
133
+
container.append(statusText);
134
+
135
+
if (kibunBase.getAttribute('data-kibun') !== 'hide') {
136
+
const kibunLink = document.createElement('a');
137
+
kibunLink.id = 'kibun-link';
138
+
kibunLink.href = 'https://www.kibun.social/';
139
+
kibunLink.setAttribute('target', '_blank');
140
+
kibunLink.setAttribute('rel', 'external');
141
+
kibunLink.textContent = 'kibun.social';
142
+
container.append(kibunLink);
143
+
}
144
+
145
+
if (kibunBase.getAttribute('data-styles') !== 'none') {
146
+
const styles = document.createElement('style');
147
+
styles.setAttribute('type', 'text/css');
148
+
styles.innerHTML = `
149
+
#kibun-container {
150
+
border: 1px #ff0000 solid;
151
+
box-shadow: 4px 4px 0 #ff0000;
152
+
padding: 20px;
153
+
max-width: 400px;
154
+
background-color: #FFFFFF;
155
+
font-family: courier new, sans-serif;
156
+
font-size: 14px;
157
+
position: relative;
158
+
margin-left: 35%;
159
+
}
160
+
161
+
#kibun-header {
162
+
display: flex;
163
+
gap: 10px;
164
+
align-items: center;
165
+
flex-wrap: wrap;
166
+
}
167
+
168
+
#kibun-displayname {
169
+
color: black;
170
+
font-weight: bold;
171
+
}
172
+
173
+
#kibun-handle {
174
+
color: #666666;
175
+
font-size: .8em;
176
+
}
177
+
178
+
#kibun-datetime {
179
+
color: #666666;
180
+
font-size: .8em;
181
+
}
182
+
183
+
#kibun-datetime:before {
184
+
content: "•";
185
+
margin-right: 10px;
186
+
}
187
+
188
+
#kibun-status {
189
+
margin-top: 10px;
190
+
}
191
+
192
+
#kibun-link {
193
+
position: absolute;
194
+
bottom: 5px;
195
+
right: 5px;
196
+
font-size: .6em;
197
+
color: #666666;
198
+
}
199
+
`;
200
+
document.body.append(styles);
201
+
}
202
+
document.body.append(container);
203
+
}
204
+
205
+
getLatest();
206
+
</script>
207
+
</div>
208
+
209
+
<center><table style="font-size: 1.2em; font-family: courier new; margin-left: 25px;"><tr style="padding: 15px;"><td>🦋 <a href="https://bsky.app/profile/tigerlily.cafe">bsky</a> <br>
49
210
🍃 <a href="https://devil.leaflet.pub/">leaflet</a> <br>
50
211
🐘 mastodon tbd <br>
51
212
🌊 <a href="https://tidal.com/@tigerlily">tidal</a> <br>
···
60
221
🎵 <a href="https://www.last.fm/user/irohman">last.fm</a><br>
61
222
🌱 <a href="https://hell.leaflet.pub/">leaflet #2</a> <br>
62
223
🔫 <a href="https://devil.hotglue.me/?start">hotglue</a> <br>
63
-
🌠 i need to join more websites now<br></td></tr></table></center>
224
+
🌠 <a href="https://tangled.org/strings/did:plc:2sqok7oqqrhtmmmb5sulkrw2/3m6cyhxo2pw22">kibun widget</a><br></td>
225
+
</tr></table></center>
226
+
<br>
64
227
</div>
228
+
65
229
</body>
66
230
</html>