NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Cryptopals challenge nav
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add forward / back buttons to cryptopals challenges
// @author Tom V
// @license MIT
// @match https://cryptopals.com/sets/*
// @require https://code.jquery.com/jquery-3.5.1.min.js
// ==/UserScript==
(function() {
'use strict';
jQuery(document).ready(function($) {
var link = $('ul.breadcrumb li:eq(2) a')
if (link.length){
var url = link.attr('href')
var chal = parseInt(url.split('/').slice(-1)[0])
var prev_url = url.replace(/\d+$/, chal - 1)
var next_url = url.replace(/\d+$/, chal + 1)
link.after($('<a> + </a>').attr('href', next_url))
link.after($('<a> – </a>').attr('href', prev_url))
}
var current_set = parseInt(document.location.pathname.match(/sets\/(\d+)/)[1])
var set = $('ul.breadcrumb li:eq(1) a')
set.after($('<a> + </a>').attr('href', `/sets/${current_set + 1}`))
set.after($('<a> – </a>').attr('href', `/sets/${current_set - 1}`))
})
})();