Pages Browsing for Wall

Adds navigation to the user wall.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Pages Browsing for Wall
// @namespace    pxgamer
// @version      0.1
// @description  Adds navigation to the user wall.
// @author       pxgamer
// @include      *kat.cr/user/*/
// @include      *kat.cr/user/*/?page=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function getQueryVar(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }

    var user        = location.href.split("/")[4];
    var currentPage = getQueryVar("page");
    var nextPage    = 2;
    var prevPage    = 0;

    if (currentPage > 1) {
        nextPage = parseInt(currentPage, 10) + 1;
        prevPage = currentPage - 1;
    }
    if (currentPage <= 1) {
        nextPage = parseInt(currentPage, 10) + 1;
        prevPage = currentPage;
    }

    $('h2:contains("The Wall")').after('<div class="wallNav"><a class="turnoverButton siteButton bigButton kaTurnoverButton pageSpecButton" title="Go to a specific page"><i class="ka ka-zoom"></i></a> <a href="?page='+prevPage.toString()+'" class="siteButton bigButton turnoverButton"><</a> <a href="?page='+nextPage.toString()+'" class="siteButton bigButton turnoverButton">></a></div><br/>');
    $('a.pageSpecButton').on('click', function() {
        var page = prompt("Please enter a page number", "");
        if (page !== null) {
            location.href = 'https://kat.cr/user/'+user+'/?page=' + page;
        }
    });
})();