Skip to content

Instantly share code, notes, and snippets.

@zuphilip
Last active May 12, 2022 18:45
Show Gist options
  • Save zuphilip/eabb4f0976b6266259c34ac032d9c3ff to your computer and use it in GitHub Desktop.
Save zuphilip/eabb4f0976b6266259c34ac032d9c3ff to your computer and use it in GitHub Desktop.
JS Bookmarklet which shows your saved reviews in ConfTool overview page

Show my reviews in ConfTool overview page

This JavaScript bookmarklet shows your saved reviews in the ConfTool overview page.

  1. Create a new bookmark in your browser
  2. Choose any name
  3. Copy the content of showMyReviews.bookmarklet.js as its adress
  4. Save it
  5. Navigate to your ConfTool website with the overview page of all your reviews, e.g. https://www.conftool.com/oat21/index.php?page=browseAssignedPapers&form_track=0
  6. Click on the newly created bookmarklet in your browser twice (first time will enrich the site with your reviews, second time will then do the reordering)

The javascript code goes all your reviews and copy the grades as well as any comments into the overview pages. This happens purely in your browser at the current session. Whenever you reload the website, you will see again the normal overview from ConfTool.

The bookmarklet code is only a rewrite of the fully formatted javascript code also below using this online tool.

javascript:(function()%7Bvar%20elements%20%3D%20document.querySelectorAll('div%5Balign%3D%22left%22%5D')%3Bfor%20(let%20el%20of%20elements)%20%7Blet%20reviewLink%20%3D%20el.querySelector('a%5Bhref*%3D%22%3Fpage%3DreviewDetailsPC%22%5D')%3Bif%20(!reviewLink)%20continue%3Bif%20(!el.dataset.score)%20%7BappendReview(el%2C%20reviewLink.href)%3B%7D%7Dvar%20nodeList%20%3D%20Array.prototype.slice.call(elements)%3BnodeList.sort(function%20(a%2C%20b)%20%7Breturn%20a.dataset.score%20%3E%20b.dataset.score%20%3F%201%20%3A%20-1%3B%7D)%3Bvar%20anchor%20%3D%20document.getElementById(%22ctform_reviewfilter%22)%3Bfor%20(let%20node%20of%20nodeList)%20%7Bnode.setAttribute(%22style%22%2C%20%22padding-bottom%3A%2032px%3B%22)%3BinsertAfter(node%2C%20anchor)%3B%7Dfunction%20appendReview(node%2C%20url)%20%7Bvar%20request%20%3D%20new%20XMLHttpRequest()%3Brequest.open(%22GET%22%2C%20url%2C%20true)%3Brequest.responseType%20%3D%20%22document%22%3Brequest.onreadystatechange%20%3D%20function(e)%20%7Bif%20(request.readyState%20%3D%3D%3D%204)%20%7Bif%20(request.status%20%3D%3D%3D%20200)%20%7Blet%20reviewDoc%20%3D%20request.response%3Blet%20reviewValues%20%3D%20reviewDoc.querySelector(%22div.infoview_body%3Etable%22)%3Bif%20(reviewValues)%20%7Blet%20grandparent%20%3D%20reviewValues.parentNode.parentNode%3Blet%20reviewComments%20%3D%20grandparent%3Bfor%20(let%20i%20%3D%200%3B%20i%20%3C%205%3B%20i%2B%2B)%20%7BreviewComments%20%3D%20reviewComments.nextSibling%3Bif%20(reviewComments.textContent.trim()%20!%3D%20%22%22)%20%7Bbreak%3B%7D%7Dnode.appendChild(reviewComments)%3Bnode.appendChild(reviewValues)%3Blet%20score%20%3D%20reviewValues.querySelector(%22td%3Alast-child%20span%3Alast-child%22).textContent%3Bif%20(score)%20%7Bscore%20%3D%20parseFloat(score)%3Bnode.dataset.score%20%3D%20score%3B%7D%7D%7D%20else%20%7Bconsole.error(request.status%2C%20request.statusText)%3B%7D%7D%7D%3Brequest.onerror%20%3D%20function(e)%20%7Bconsole.error(request.status%2C%20request.statusText)%3B%7D%3Brequest.send(null)%3B%7Dfunction%20insertAfter(newNode%2C%20existingNode)%20%7BexistingNode.parentNode.insertBefore(newNode%2C%20existingNode.nextSibling)%3B%7D%7D)()
var elements = document.querySelectorAll('div[align="left"]');
for (let el of elements) {
let reviewLink = el.querySelector('a[href*="?page=reviewDetailsPC"]');
if (!reviewLink) continue;
if (!el.dataset.score) {
appendReview(el, reviewLink.href);
}
}
var nodeList = Array.prototype.slice.call(elements);
nodeList.sort(function (a, b) {
return a.dataset.score > b.dataset.score ? 1 : -1;
});
var anchor = document.getElementById("ctform_reviewfilter");
for (let node of nodeList) {
node.setAttribute("style", "padding-bottom: 32px;");
insertAfter(node, anchor);
}
function appendReview(node, url) {
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.responseType = "document";
request.onreadystatechange = function(e) {
if (request.readyState === 4) {
if (request.status === 200) {
let reviewDoc = request.response;
let reviewValues = reviewDoc.querySelector("div.infoview_body>table");
if (reviewValues) {
let grandparent = reviewValues.parentNode.parentNode;
let reviewComments = grandparent;
for (let i = 0; i < 5; i++) {
reviewComments = reviewComments.nextSibling;
if (reviewComments.textContent.trim() != "") {
break;
}
}
node.appendChild(reviewComments);
node.appendChild(reviewValues);
let score = reviewValues.querySelector("td:last-child span:last-child").textContent;
if (score) {
score = parseFloat(score);
node.dataset.score = score;
}
}
} else {
console.error(request.status, request.statusText);
}
}
};
request.onerror = function(e) {
console.error(request.status, request.statusText);
};
request.send(null);
}
function insertAfter(newNode, existingNode) {
existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment