The following script is meant to be a user script, but it should work on the console. It takes the id of the question and adds the corresponding /posts/id/timeline
link to the post-menu element, just besides others. It's meant to not have problem with other scripts. The same as above for the answers, just that in this case it should loop through all the answers and add its corresponding timeline link.
let question = document.getElementById("question");
let qid = question.dataset.questionid;
if (qid) {
let span = document.createElement("span");
let alink = document.createElement("a");
alink.class = "userscript-timeline";
alink.href = "/posts/" + Number(qid) + "/timeline";
alink.title = "timeline for this question";
alink.textContent = "timeline";
span.appendChild(alink);
question.getElementsByClassName("post-menu")[0].appendChild(span);
}
let answers = document.getElementsByClassName("answer");
if (answers) {
for (let i = 0; i < answers.length; i += 1) {
let aid = answers[i].dataset.answerid;
let answer = document.getElementById("answer-" + aid);
let span = document.createElement("span");
let alink = document.createElement("a");
alink.class = "userscript-timeline";
alink.href = "/posts/" + Number(aid) + "/timeline";
alink.title = "timeline for this answer";
alink.textContent = "timeline";
span.appendChild(alink);
answer.getElementsByClassName("post-menu")[0].appendChild(span);
}
}
I'm not sure if it's convenient to abstract the logic that create and adds the link, as I'm afraid it could introduce needless complexity. My naming sense could be better.