Skip to content

Instantly share code, notes, and snippets.

@agate
Last active November 2, 2015 10:41
Show Gist options
  • Save agate/8db8be824eaddb95def4 to your computer and use it in GitHub Desktop.
Save agate/8db8be824eaddb95def4 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 4clojure navigate buttons
// @namespace http://agate.github.com
// @version 0.1
// @description add a prev / next button for problem page
// @author agate
// @match https://www.4clojure.com/problem/*
// @match http://www.4clojure.com/problem/*
// @grant none
// ==/UserScript==
$(function () {
var id = parseInt(location.href.match(/\/(\d+)$/)[1]);
if (location.href.match(/solutions/)) {
var html = '<a href="/problem/' + id + '"><button id="back-link">Back</button></a>'
$('h3').append(html);
} else {
var prev = id - 1;
var next = id + 1;
if (prev >= 1) {
var html = '<a href="/problem/' + prev + '"><button id="prev-link" style="margin-left: 20px;margin-top: -1px;">Prev</button></a>'
$('hr:first').before(html);
}
var html = '<a href="/problem/' + next + '"><button id="next-link" style="margin-left: 20px;margin-top: -1px;">Next</button></a>'
$('hr:first').before(html);
var html = '<a href="https://gist.github.com/agate/a62ad1a851f7d3d58430#problem-' + id + '"><button id="answer-link" style="margin-left: 20px;margin-top: -1px;">Answer</button></a>'
$('hr:first').before(html);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment