SteamGifts - Extended Navigation

Extended Navigation: Fixes last page + find last comment.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         SteamGifts - Extended Navigation
// @version      0.3
// @description  Extended Navigation: Fixes last page + find last comment.
// @author       Royalgamer06
// @include      *steamgifts.com/discussion/*
// @grant        none
// @namespace    Royalgamer06
// ==/UserScript==

var always = false;

$(document).ready(function() {
    if ($('.pagination__navigation').find('.fa-angle-double-right').length === 0) {
        var href = location.href.split('/discussion/')[1].split('/');
        href = href[0] + '/' + href[1].split('#')[0];
        href = '/discussion/' + href + '/search?page=4096';
        $('.pagination__navigation').append('<a href="' + href + '"><span>Last</span> <i class="fa fa-angle-double-right"></i></a>');
    }
    if (always) {
        navLatestComment();
    } else {
        $('.page__heading__breadcrumbs:last').append('<pre>  -  </pre><a style="cursor: pointer;" id="lastcomment">Find most recent comment on page</a>');
        $('#lastcomment').on('click', function() {
            navLatestComment();
            $(this).hide();
            $(this).parent().find('pre').hide();
        });
    }
});

function navLatestComment() {
    var comment_elements = document.querySelectorAll('div[data-comment-id]');
    var comment_latest = 0;
    for (var i = 0; i < comment_elements.length; i++) {
        if (comment_elements[i].getAttribute('data-comment-id') > comment_latest) {
            comment_latest = comment_elements[i].getAttribute('data-comment-id');
        }
    }
    var comment_id = document.querySelector('div[data-comment-id="' + comment_latest + '"] .comment__summary').getAttribute('id');
    if (location.href.indexOf('#') == -1) {
        location.href = location.href + '#' + comment_id;
    } else {
        location.href = location.href.split('#')[0] + '#' + comment_id;
    }
}