random bun scripts that dont fit anywhere else
1// ==UserScript==
2// @name Amazon URL Cleaner
3// @namespace https://tangled.sh/@dunkirk.sh/bunplayground/amazon-shortener
4// @version 0.1
5// @description Removes fluff from Amazon URLs to get clean product links
6// @author You
7// @match https://www.amazon.com/*
8// @grant none
9// @run-at document-start
10// ==/UserScript==
11
12(() => {
13 function cleanURL() {
14 const url = window.location.href;
15 const match = url.match(/amazon\.com.*?\/([A-Z0-9]{10})/);
16 if (match) {
17 const asin = match[1];
18 const clean = `https://www.amazon.com/dp/${asin}`;
19 if (url !== clean) {
20 window.history.replaceState(null, "", clean);
21 }
22 }
23 }
24
25 cleanURL();
26
27 window.addEventListener("locationchange", cleanURL);
28 window.addEventListener("popstate", cleanURL);
29})();