Skip to content

Instantly share code, notes, and snippets.

@sleemanj
Last active April 28, 2021 02:07
Show Gist options
  • Save sleemanj/352f095f6f67564dae825f79204f1f01 to your computer and use it in GitHub Desktop.
Save sleemanj/352f095f6f67564dae825f79204f1f01 to your computer and use it in GitHub Desktop.
Tampermonkey Script to Collapse your Aliexpress "My Orders" page and highlight orders which are Awaiting Delivery based on days remaining, light blue more than 28 days remain, orange more than 7 days, RED less than 7 days.
// ==UserScript==
// @name Collapse Order History on Aliexpress and highlight time remaining for orders awaiting delivery.
// @namespace https://gist.github.com/sleemanj/352f095f6f67564dae825f79204f1f01
// @updateURL https://gist.github.com/sleemanj/352f095f6f67564dae825f79204f1f01/raw/aliexpress-order-list-collapse.js
// @downloadURL https://gist.github.com/sleemanj/352f095f6f67564dae825f79204f1f01/raw/aliexpress-order-list-collapse.js
// @version 1.2
// @description Collapse the orders in My Orders to make the page more compact, highlight "Awaiting Delivery" ones.
// @author James Sleeman
// @match *://trade.aliexpress.com/orderList.htm*
// @grant GM_addStyle
// ==/UserScript==
(function(){
var orders = document.getElementsByClassName('order-item-wraper');
for(var i = 0; i < orders.length; i++)
{
var tbody = orders[i];
var x;
// Find all the "product-left" which contains the photo and put them into the first product-sets
var lefts = tbody.getElementsByClassName('product-left');
for(x = 1; x < lefts.length; x++)
{
lefts[0].parentNode.appendChild(lefts[x]);
}
// Find all the product-rights and delete them (titles, prices etc)
var rights = tbody.getElementsByClassName('product-right');
for(x = rights.length-1; x >= 0; x--)
{
rights[x].remove();
}
// Find all the product-actions and delete them (dispute links)
var actions = tbody.getElementsByClassName('product-right');
for(x = actions.length-1; x >= 0; x--)
{
actions[x].remove();
}
// Find all the order-body except the first and delete them (additional products same order, we already snagged the images above)
var bodies = tbody.getElementsByClassName('order-body');
for(x = bodies.length-1; x >= 1; x--)
{
bodies[x].remove();
}
// Find the status
var status = tbody.getElementsByClassName('order-status')[0].getElementsByClassName('f-left')[0].innerText.trim();
switch(status)
{
case 'Awaiting delivery':
// Find how many days left
var days = 0;
if(tbody.getElementsByClassName('order-status')[0].getElementsByClassName('left-sendgoods-day')[0].innerText.trim().match(/\s([0-9]+)\sdays/))
{
days = RegExp.$1;
}
var bgcol = 'red';
if(days > 28)
{
bgcol = 'rgb(215, 224, 255)';
}
else if(days > 7)
{
bgcol = 'rgb(255, 183, 75)';
}
tbody.style.backgroundColor=bgcol;
break;
case 'Finished':
case 'Fund Processing':
{
tbody.style.opacity = 0.25;
}
break;
default:
break;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment