Torn City - Attack Logs extension

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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;
}