Torn City - Attack Logs extension

This script adds a Next and Previous button to the Attack Logs page.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @author        Xiphias[187717]
// @name          Torn City - Attack Logs extension
// @description   This script adds a Next and Previous button to the Attack Logs page.
// @include       http://www.torn.com/attacklogs.php*
// @include       http://torn.com/attacklogs.php*
// @include       https://www.torn.com/attacklogs.php*
// @include       https://torn.com/attacklogs.php*
// @version       1.0.0
// @namespace https://greasyfork.org/users/3898
// ==/UserScript==

$(document).ready(function() {
    runScript();
});

function addButtons(currentUserID) {

    var prevUserID = Number(currentUserID) - 1;
    var nextUserID = Number(currentUserID) + 1;
    
    var before = '<a href="/attacklogs.php?ID=' + (prevUserID) + 
    '" style="float: left;"> &lt; Previous</a>';
    
    var after = '<a href="/attacklogs.php?ID=' + (nextUserID) + '" style="float: right;">Next &gt; </a>';

    $('center > a[href="events.php"]').before(before);
    $('center > a[href="events.php"]').after(after);
}

function runScript() {
    var currentUserID  = getUserID();
    addButtons(currentUserID);
}

function getUserID() {
    var path = window.location;
    var search = path.search;
    var userID = search.substring(search.indexOf('ID=')+3);

    return userID;
}