Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#83 user badges on note page
Browse files Browse the repository at this point in the history
deevroman committed Dec 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 642aaca commit 09c33e0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion better-osm-org.user.js
Original file line number Diff line number Diff line change
@@ -818,6 +818,11 @@ function addResolveNotesButtons() {
if (document.querySelector('#timeback-btn')) return true;
blurSearchField();

document.querySelectorAll('#sidebar_content a[href^="/user/"]').forEach(elem => {
getCachedUserInfo(elem.textContent).then(info => {
elem.before(makeBadge(info, new Date(elem.parentElement.querySelector("time")?.getAttribute("datetime") ?? new Date())))
})
})
document.querySelectorAll(".overflow-hidden a").forEach(i => {
i.setAttribute("target", "_blank")
})
@@ -5390,7 +5395,17 @@ async function updateUserInfo(username) {
limit: 1
}).toString());
const res = await rawRes.json()
const uid = res['changesets'][0]['uid']
let uid;
if (res['changesets'].length === 0) {
const rawRes = await fetch(osm_server.apiBase + "notes/search.json?" + new URLSearchParams({
display_name: username,
limit: 1
}).toString());
const res = await rawRes.json()
uid = res['features'][0]['properties']['comments'][0]['uid']
} else {
uid = res['changesets'][0]['uid']
}

const rawRes2 = await fetch(osm_server.apiBase + "user/" + uid + ".json");
const res2 = await rawRes2.json()

0 comments on commit 09c33e0

Please sign in to comment.