Last active
May 9, 2021 10:25
-
-
Save featherbear/737cf59ba9f6fbbba0e0fb224a412dc2 to your computer and use it in GitHub Desktop.
AliExpress GST Modifier (Australia)
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 GST in Australia | |
// @namespace http://tampermonkey.net/aliexpress-gst | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.aliexpress.com/* | |
// @icon https://www.google.com/s2/favicons?domain=aliexpress.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let elsByClassName = (cls) => [...document.getElementsByClassName(cls)]; | |
window.addEventListener('load', function() { | |
setTimeout(function() { | |
const selectors = [ | |
...elsByClassName("product-price-value"), | |
...elsByClassName("simple-card-price"), | |
...elsByClassName("price-current"), | |
...document.querySelectorAll(".product-shipping-price .bold") | |
] | |
selectors.forEach(e => { | |
let changedText = e.innerText | |
.replace( | |
/\$(\d+(?:\.\d{1,2})?)/g, | |
(_, capture) => `$${(Number(capture)*1.1).toFixed(2)}` | |
) | |
.replace( | |
/(\$\d+(?:\.\d{1,2}) - )\d+(?:\.\d{1,2})?/g, | |
(match, capture) => `${capture}${(Number(match.slice(capture.length))*1.1).toFixed(2)}` | |
) | |
if (changedText != e.innerText) { | |
console.log("Changing text for", e, "from", e.innerText, "to", changedText); | |
e.innerText = changedText; | |
} | |
}) | |
}, 1000) | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment