Amazon Autopager

Loads next page of search results automatically on Amazon

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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