forked from SO-Close-Vote-Reviewers/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReviewLinks.user.js
29 lines (27 loc) · 1.07 KB
/
ReviewLinks.user.js
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
// ==UserScript==
// @name Review links
// @namespace https://github.com/Gothdo
// @version 1.1
// @description If a question or an answer is currently in a review queue, adds a link to it.
// @author Gothdo
// @match *://stackoverflow.com/questions/*
// @grant none
// ==/UserScript==
function addReviewLink(isQuestion, postId) {
$.get(`/posts/${postId}/timeline`)
.then(page=> {
const $reviewLink = $(page).find(".event-type.review").parent().parent().find(".event-verb a")
if ($reviewLink.length === 1) {
const reviewURL = $reviewLink.attr("href")
,reviewName = $reviewLink.text()
,postMenuSelector = (isQuestion ? "#question" : `.answer[data-answerid=${postId}]`) + " .post-menu"
$(postMenuSelector).append(`<span class="lsep">|</span><a href="${reviewURL}">${reviewName} review</a>`)
}
})
}
StackExchange.ready(()=> {
addReviewLink(true, StackExchange.question.getQuestionId())
$(".answer").each(function() {
addReviewLink(false, $(this).attr("data-answerid"))
})
})