Greasy Fork is available in English.

BrickLink - Navigate Between Orders

Adds buttons to quickly switch between orders on the Order Detail page.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        BrickLink - Navigate Between Orders
// @name:en     BrickLink - Navigate Between Orders
// @namespace   Violentmonkey Scripts
// @match       https://www.bricklink.com/orderPlaced.asp*
// @match       https://www.bricklink.com/orderDetail.asp*
// @grant       GM.setValue
// @grant       GM.getValue
// @version     0.2
// @author      The0x539
// @description Adds buttons to quickly switch between orders on the Order Detail page.
// @license     AGPL-3.0
// ==/UserScript==

function stashOrderIds() {
	const elements = document.querySelectorAll('table.orders-table > * > tr:not(:first-child) > td:first-child > a');
	const ids = [...elements].map(id => id.textContent);
	ids.sort();
	GM.setValue('order-ids', ids);

	// TODO: Improve this to use data from past page loads rather than replacing everything with whatever was seen most recently
}

async function addLinks() {
	const header = document.querySelector('center > div');

	const mainHeader = header.firstElementChild;
	mainHeader.classList.replace('left', 'center');

	const ids = await GM.getValue('order-ids', []);

	if (ids.length < 2) return;

	const currentId = new URLSearchParams(location.search).get('ID');
	const i = ids.findIndex(v => v === currentId);
	if (i < 0) return;

	if (i - 1 > 0) {
		const link = document.createElement('a');
		link.href = `orderDetail.asp?ID=${ids[i-1]}`;
		link.innerHTML = '<< Previous';
		link.style.float = 'left';
		header.insertBefore(link, mainHeader);
	}
	if (i + 1 < ids.length) {
		const link = document.createElement('a');
		link.href = `orderDetail.asp?ID=${ids[i+1]}`;
		link.innerHTML = 'Next >>';
		link.style.float = 'right';
		header.insertBefore(link, mainHeader);
	}
}

if (location.pathname.includes('orderPlaced.asp')) {
	stashOrderIds();
} else {
	addLinks();
}