SteamGifts - Extended Navigation

Extended Navigation: Fixes last page + find last comment.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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