-
-
Save coreequip/3cd548d31e55288091dba44ad4dddc4b to your computer and use it in GitHub Desktop.
Aliexpress/eBay/Gearbest URL Shortener
This file contains 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/eBay/Gearbest/Amazon URL Shortener | |
// @namespace http://tampermonkey.net/ | |
// @version 0.5 | |
// @author hedgehog, core.equip | |
// @match https://*.aliexpress.com/item/* | |
// @match https://*.ebay.de/itm/* | |
// @match https://*.ebay.com/itm/* | |
// @match https://*.gearbest.com/* | |
// @match https://*.amazon.de/* | |
// @match https://*.amazon.co.uk/* | |
// @match https://*.amazon.es/* | |
// @match https://*.amazon.com/* | |
// @grant none | |
// ==/UserScript== | |
((w, l, h) => { | |
'use strict' | |
let shops = { | |
aliexpress: [/^(https?:\/\/[a-z]+\.aliexpress\.com\/item\/)[^/]+(\/[0-9]+\.html)\??.*$/, '$1-$2'], | |
ebay: [/^(https?:\/\/www\.ebay(?:\.[a-z]+)+\/itm\/)[^\/]+(\/[0-9]+)\??.*$/, '$1-$2'], | |
gearbest: [/^(https?:\/\/www\.gearbest\.com\/)[^\/]+(\/pp_[0-9]+\.html)\??.*$/, '$1-$2'], | |
amazon: [/^(https?:\/\/\w+\.amazon\.[\w.]+\/).*?\/(B[A-Z0-9]+).*$/, '$1dp/$2'] | |
} | |
w.addEventListener('load', function load(event) { | |
w.removeEventListener('load', load, false) | |
Object.keys(shops).forEach((replace) => h.pushState({}, '', l.href.replace(shops[replace][0], shops[replace][1]))) | |
},false); | |
})(window, window.location, window.history); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment