Last active
December 30, 2019 23:55
-
-
Save vogler/6d29fa58650fe976a5a4360be0a6b594 to your computer and use it in GitHub Desktop.
Tampermonkey: AliExpress: Orders: Enter = search, use https
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name AliExpress: Orders: Enter = search, use https | |
// @namespace https://gist.github.com/vogler | |
// @downloadURL https://gist.github.com/vogler/6d29fa58650fe976a5a4360be0a6b594/raw/fix-search.aliexpress.tamper.js | |
// @version 0.3 | |
// @description Hitting 'Enter' should start the search in 'Orders', always use https | |
// @author Ralf Vogler | |
// @match *://trade.aliexpress.com/order*ist.htm* | |
// there are links to order_list.htm and orderList.html | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// the link to 'Orders' in the user menu is https://trade.alibaba.com/order_list.htm which redirects to http://trade.aliexpress.com/order_list.htm of https://... | |
// fix the link in the menu to go directly to https://trade.aliexpress.com/order_list.htm like the other links to 'Orders' | |
// link has no id, just index into it, maybe better if fragile: https://stackoverflow.com/questions/3813294/how-to-get-element-by-innertext | |
document.querySelector('#nav-user-account').querySelectorAll('a')[8].href = 'https://trade.aliexpress.com/order_list.htm' | |
// and redirect to https if we get there some other way | |
if (location.href.startsWith('http:')) { | |
alert('Requested order list via http; redirect to https...') | |
location.href = location.href.replace('http:', 'https:') | |
} | |
// search when hitting Enter instead of having to click the button | |
document.querySelector('#product-name').onkeydown = e => { if(e.key == 'Enter') document.querySelector('#search-btn').click() } | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment