Amazon Autopager

Loads next page of search results automatically on Amazon

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==
// @name			Amazon Autopager
// @version			1.03
// @author			XFox Prower
// @namespace		http://www.TailsArchive.net/
// @description		Loads next page of search results automatically on Amazon
// @include			https://www.amazon.com/s/*
// @include			https://smile.amazon.com/s/*
// @include			https://www.amazon.co.uk/s/*
// @include			https://www.amazon.co.jp/s/*
// @grant			none
// ==/UserScript==

'use strict';

function fscroll()
	{
	var	next=D.getElementById('pagnNextLink'),
		cont,
		pager,
		req;

	if(!next||lock){return;}
	if(next.getBoundingClientRect().bottom<innerHeight>>1)
		{
		lock=1;
		cont=D.getElementById('s-results-list-atf');
		pager=D.getElementById('pagn');
		req=new XMLHttpRequest();
		req.open('GET',next.href);
		req.responseType='document';
		req.onload=function()
			{
			var	res=req.response,
				frag=D.createDocumentFragment(),
				col=res.querySelectorAll('li[id^=result_]'),
				len=col.length,
				i;

			for(i=0;i<len;i++)
				{
				frag.appendChild(col.item(i));
				}
			cont.appendChild(frag);
			pager.parentNode.replaceChild(res.getElementById('pagn'),pager);
			lock=0;
			};
		req.send();
		}
	}

var	D=document,
	lock=0;

addEventListener('scroll',fscroll);