Amazon Autopager

Loads next page of search results automatically on Amazon

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);