Tom's Hardware Paginator Remover

Visualizza gli articoli multipagina in una pagina sola.

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     Fra85
// @name        Tom's Hardware Paginator Remover
// @namespace   greasemonkey.tomshardware.paginator_remover
// @description Visualizza gli articoli multipagina in una pagina sola.
// @include     http://www.tomshw.it/
// @version     1.2
// @domain          tomshw.it
// @match           http://www.tomshw.it/*
// @grant       none
// ==/UserScript==
if (document.getElementsByTagName("title").length === 0) return;


$(function() {

    var ll = $("#sticky-pagination ol li:last-child a").attr("href");
    if (!ll) return;

    function getPageNum(url) {
        var n = url.substring(url.lastIndexOf('-p') + 2);
        return isFinite(n) ? n : 1;
    };

    function getPageUrl(base, page) {
        return (page == 1) ? base : base + "-p" + page;
    }

    function contains(str, key) {
        return (str.indexOf(key) > -1);
    }

    var titles = [];
    $("#sticky-pagination ol li a").each(function() {
        titles.push($(this).text());
    });

    function getTitle(page) {
        return "<h3>" + titles[page - 1] + "</h3>";
    }

    var npages = ll.substring(ll.lastIndexOf('-p') + 2);
    var baseurl = ll.substring(0, ll.lastIndexOf('-p'));
    var start = 1;

    if (getPageNum(window.location.pathname) == 1) {
        if (!contains($("#intelliTxt").html(), "<h3"))
            $("#intelliTxt").prepend(getTitle(1));
        start = 2;
    } else
        $("#intelliTxt").empty();

    $("#sticky-pagination, .pagination_summary").remove();
    $("#intelliTxt").css("background-color", "#FFF");

    for (var i = start; i <= npages; i++) {
        $("#intelliTxt").append('<div class="load-image" id="thpr-' + i + '"><i class="fa fa-spinner fa-pulse"></i></div>');
        (function(i) {
            $.get(getPageUrl(baseurl, i), {}, function(msg) {
                    var line = (i == 1) ? "" : "<hr style='border-width:4px 0 0'></hr>";
                    var title = contains(msg, "<h3") ? "" : getTitle(i);
                    $("#thpr-" + i).after(line + title + msg);
                    $("#thpr-" + i).remove();
                })
                .fail(function() {
                    alert("Errore download pagina " + i);
                });
        })(i);
    }
});