Skip to content

Instantly share code, notes, and snippets.

@jamezpolley
Forked from mithro/symposium-review-extra.js
Last active August 2, 2018 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamezpolley/a086bcba602e93d7d70ad042f04c19e4 to your computer and use it in GitHub Desktop.
Save jamezpolley/a086bcba602e93d7d70ad042f04c19e4 to your computer and use it in GitHub Desktop.
GreaseMonkey / TamperMonkey script to make Linux.conf.au (Symposium) reviews a bit nicer
// ==UserScript==
// @name symposium-review-extra
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Show all the tabs in the review pane at once.
// @author You
// @match https://lca2019.linux.org.au/reviews/review/.*
// @match https://lca2019.linux.org.au/reviews/review/*
// @downloadURL https://gist.githubusercontent.com/jamezpolley/a086bcba602e93d7d70ad042f04c19e4/raw/a2f92ce041275185d972ab272900a5b2d74efd87/symposium-review-extra.js
// @updateURL https://gist.githubusercontent.com/jamezpolley/a086bcba602e93d7d70ad042f04c19e4/raw/a2f92ce041275185d972ab272900a5b2d74efd87/symposium-review-extra.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Import showdown for markdown rendering...
var imported = document.createElement('script');
imported.src = 'https://cdnjs.cloudflare.com/ajax/libs/showdown/1.7.2/showdown.min.js';
imported.onload = function() {
// Convert the comments from markdown
renderMarkdownComments(document.getElementsByClassName("review-content"));
};
document.head.appendChild(imported);
function renderMarkdownComments(elements) {
var converter = new showdown.Converter();
for (var i=0, len=elements.length; i<len; i++) {
// Find the element which has the actual comment in it
var n = elements[i].childNodes;
var last = n[n.length-1];
// Render the element into HTML
var element = document.createElement('div');
element.innerHTML = converter.makeHtml(last.data.trim());
last.replaceWith(element);
}
}
function display(elements, value){
for (var i=0, len=elements.length; i<len; i++) {
elements[i].style["display"] = value;
}
}
if (document.getElementById("proposal-detail") !== null) {
// Show all tabs
console.log("Enabling all tabs");
document.getElementById("proposal-detail").classList.add("active");
document.getElementById("proposal-reviews").classList.add("active");
document.getElementById("proposal-feedback").classList.add("active");
// Move the review form to a better location
var f = document.getElementsByClassName("review-form")[0];
f.parentNode.removeChild(f);
var pd = document.getElementById("proposal-detail");
pd.appendChild(f);
// Add a button to show/hide other people's reviews
if (document.getElementById("reviews") === null) {
console.log("Adding show/hide reviews button");
var btn = document.createElement("button");
btn.id = "reviews";
btn.onclick = function() {
var elements = document.getElementsByClassName("review-box");
if (elements[0].style["display"] == "none") {
display(elements, "");
elements[elements.length-1].scrollIntoView();
} else {
display(elements, "none");
}
};
var t = document.createTextNode("Show/Hide Reviews");
btn.appendChild(t);
document.getElementById("proposal-detail").appendChild(btn);
// Hide other people's review by default
display(document.getElementsByClassName("review-box"), "none");
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment