Skip to content

Instantly share code, notes, and snippets.

@TayIorRobinson
Last active June 26, 2025 13:00
Show Gist options
  • Save TayIorRobinson/64cad84f7fb5441f2b970ca5db16ea22 to your computer and use it in GitHub Desktop.
Save TayIorRobinson/64cad84f7fb5441f2b970ca5db16ea22 to your computer and use it in GitHub Desktop.
UserScript to return the 'Archive order' button back to the Amazon order history page.
// ==UserScript==
// @name Return Amazon Archive Button
// @namespace http://robins.one/
// @version 2025-06-26
// @description Adds the 'Archive order' button back to the Amazon order history page.
// @author Taylor
// @match *://*.amazon.com.au/gp/*/order-history*
// @match *://*.amazon.com.au/your-orders/*
// @match *://*.amazon.com.be/gp/*/order-history*
// @match *://*.amazon.com.be/your-orders/*
// @match *://*.amazon.com.br/gp/*/order-history*
// @match *://*.amazon.com.br/your-orders/*
// @match *://*.amazon.ca/gp/*/order-history*
// @match *://*.amazon.ca/your-orders/*
// @match *://*.amazon.cn/gp/*/order-history*
// @match *://*.amazon.cn/your-orders/*
// @match *://*.amazon.eg/gp/*/order-history*
// @match *://*.amazon.eg/your-orders/*
// @match *://*.amazon.fr/gp/*/order-history*
// @match *://*.amazon.fr/your-orders/*
// @match *://*.amazon.de/gp/*/order-history*
// @match *://*.amazon.de/your-orders/*
// @match *://*.amazon.in/gp/*/order-history*
// @match *://*.amazon.in/your-orders/*
// @match *://*.amazon.ie/gp/*/order-history*
// @match *://*.amazon.ie/your-orders/*
// @match *://*.amazon.it/gp/*/order-history*
// @match *://*.amazon.it/your-orders/*
// @match *://*.amazon.co.jp/gp/*/order-history*
// @match *://*.amazon.co.jp/your-orders/*
// @match *://*.amazon.com.mx/gp/*/order-history*
// @match *://*.amazon.com.mx/your-orders/*
// @match *://*.amazon.nl/gp/*/order-history*
// @match *://*.amazon.nl/your-orders/*
// @match *://*.amazon.pl/gp/*/order-history*
// @match *://*.amazon.pl/your-orders/*
// @match *://*.amazon.sa/gp/*/order-history*
// @match *://*.amazon.sa/your-orders/*
// @match *://*.amazon.sg/gp/*/order-history*
// @match *://*.amazon.sg/your-orders/*
// @match *://*.amazon.co.za/gp/*/order-history*
// @match *://*.amazon.co.za/your-orders/*
// @match *://*.amazon.es/gp/*/order-history*
// @match *://*.amazon.es/your-orders/*
// @match *://*.amazon.se/gp/*/order-history*
// @match *://*.amazon.se/your-orders/*
// @match *://*.amazon.com.tr/gp/*/order-history*
// @match *://*.amazon.com.tr/your-orders/*
// @match *://*.amazon.ae/gp/*/order-history*
// @match *://*.amazon.ae/your-orders/*
// @match *://*.amazon.co.uk/gp/*/order-history*
// @match *://*.amazon.co.uk/your-orders/*
// @match *://*.amazon.com/gp/*/order-history*
// @match *://*.amazon.com/your-orders/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.co.uk
// @grant none
// ==/UserScript==
/*
If you're just seeing this code (and not a 'add' or 'install' button), you'll need to install a browser extension.
If you're using Safari, install Userscripts from the App Store: https://apps.apple.com/us/app/userscripts/id1463298887
Firefox, Chrome, Edge, etc users should install Tampermonkey: https://tampermonkey.net
Once installed close and re-open this link: https://gist.github.com/TayIorRobinson/64cad84f7fb5441f2b970ca5db16ea22/raw/amazon-archive.user.js
*/
(function() {
'use strict';
// get the current domain we're on (i.e 'https://www.amazon.co.uk')
let origin = new URL(location.href).origin;
// find all the order ID text containers on the page
document.querySelectorAll(".yohtmlc-order-id").forEach(oid => {
// take the text and match the first sequence of digits and '-'
// turning "ORDER ID : # 123-456-789" to just "123-456-789"
let orderId = oid.innerText.match(/[\d-]+/)[0];
// create a new link element
let link = document.createElement("a");
// set text of link
link.innerText = '(archive)';
// set the link of the element to the archive this order page.
// need to pull the session ID as its used as a security (CSRF) token
link.href = origin + `/gp/css/order-history/archive?orderIds=${orderId}&archiveRequest=1&token=${window.opts.sessionId}`;
// add the link to the order id container
oid.appendChild(link);
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment