nascent / PSPrices Better Navigation

// ==UserScript==
// @name         PSPrices Better Navigation
// @namespace    https://psprices.com/
// @version      0.1
// @description  Replaces the weird back and forward navigation to me more standardised
// @author       nascent
// @match        https://psprices.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=psprices.com
// @grant        none
// @updateURL   https://openuserjs.org/meta/nascent/PSPrices_Better_Navigation.meta.js
// @downloadURL https://openuserjs.org/install/nascent/PSPrices_Better_Navigation.user.js
// @license GPL-3.0-or-later
// ==/UserScript==

(function() {
    'use strict';

    const pageReg = /page=[\d]+/g;
    const pageNumberReg = /[\d]+/g;

    var backLink;
    var nextLink;
    var currentLink;

    var currentPage = ((document.getElementsByClassName('page-item active')[0]).textContent).trim();
    var currentPageNumber = Number(currentPage);
    var backPageNumber; // = currentPageNumber-1;
    var nextPageNumber; // = currentPageNumber+1;
    var elements = document.getElementsByClassName('page-link');

    for (var i = 0; i < elements.length; ++i) {
        var item = elements[i];
        if (item.innerText.trim() == "…"){
            var temp = item.href.match(pageReg)[0];

            var temp2 = temp.match(pageNumberReg);
            temp2 = Number(temp2);
            if (temp2 < currentPageNumber){
                backPageNumber = currentPageNumber-1;

                item.innerText = "<";
                var backPageString = "page="+backPageNumber;
                item.href = item.href.replace(pageReg, backPageString);
            }
            else if(temp2 > currentPageNumber){
                nextPageNumber = currentPageNumber+1;

                var nextPageString = "page="+nextPageNumber;
                item.innerText = ">";
                item.href = item.href.replace(pageReg, nextPageString);
            }
        }
    }
})();