tomviner / Cryptopals challenge nav

// ==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>&nbsp;+&nbsp;</a>').attr('href', next_url))
            link.after($('<a>&nbsp;&#8211;&nbsp;</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>&nbsp;+&nbsp;</a>').attr('href', `/sets/${current_set + 1}`))
        set.after($('<a>&nbsp;&#8211;&nbsp;</a>').attr('href', `/sets/${current_set - 1}`))
    })
})();