tangled
alpha
login
or
join now
dunkirk.sh
/
bunplayground
1
fork
atom
random bun scripts that dont fit anywhere else
1
fork
atom
overview
issues
pulls
pipelines
feat: add amazon link cleaner
dunkirk.sh
10 months ago
a750c2d1
c34a22cd
verified
This commit was signed with the committer's
known signature
.
dunkirk.sh
SSH Key Fingerprint:
SHA256:DqcG0RXYExE26KiWo3VxJnsxswN1QNfTBvB+bdSpk80=
+29
1 changed file
expand all
collapse all
unified
split
amazon-shortener.user.js
+29
amazon-shortener.user.js
···
1
1
+
// ==UserScript==
2
2
+
// @name Amazon URL Cleaner
3
3
+
// @namespace https://tangled.sh/@dunkirk.sh/bunplayground/amazon-shortener
4
4
+
// @version 0.1
5
5
+
// @description Removes fluff from Amazon URLs to get clean product links
6
6
+
// @author You
7
7
+
// @match https://www.amazon.com/*
8
8
+
// @grant none
9
9
+
// @run-at document-start
10
10
+
// ==/UserScript==
11
11
+
12
12
+
(() => {
13
13
+
function cleanURL() {
14
14
+
const url = window.location.href;
15
15
+
const match = url.match(/amazon\.com.*?\/([A-Z0-9]{10})/);
16
16
+
if (match) {
17
17
+
const asin = match[1];
18
18
+
const clean = `https://www.amazon.com/dp/${asin}`;
19
19
+
if (url !== clean) {
20
20
+
window.history.replaceState(null, "", clean);
21
21
+
}
22
22
+
}
23
23
+
}
24
24
+
25
25
+
cleanURL();
26
26
+
27
27
+
window.addEventListener("locationchange", cleanURL);
28
28
+
window.addEventListener("popstate", cleanURL);
29
29
+
})();