diy solar

diy solar

Enhancement Request: Clean Amazon URLs

rmaddy

Full-time Solar-powered Trailer Life
Joined
Nov 16, 2019
Messages
3,737
Location
USA
Would it be possible to update the forum software so it strips Amazon URLs to the bare minimum needed? Many people paste Amazon URLs into posts and most of these URLs contain far more junk than is necessary.

Many look like this:

Code:
https://www.amazon.com/Some-Product-Name/dp/SomeASIN/ref=junk?crid=more_junk&keywords=search+terms&qid=junk&sprefix=more%20junk&sr=junk

All that is needed is either:

Code:
https://www.amazon.com/Some-Product-Name/dp/SomeASIN

or:

Code:
https://www.amazon.com/dp/SomeASIN

Stripping everything after the ASIN should be simple enough.
 
I always look for the "?" question mark and delete all that follows. Too bad the "post link" function can't have a script to do this automatic.

Same as when I save a link or favorite on my own computer.
 
The fbclid=FarcebookTrackingCode and related would be nice to strip fro all URLs, while the parser is being added.
 
I don't remember where I got it (or how much I've modified it), but I use this Greasemonkey/Tampermonkey script which cleans the urls upon loading them;

JavaScript:
// ==UserScript==
// @id             Amazon URL Cleaner
// @name           Amazon URL Cleaner
// @namespace      http://efcl.info/
// @description    replaceState for Amazon
// @include        /^https?:\/\/www.amazon.*\/dp\/*/
// @include        /^https?:\/\/www.amazon.*\/*gp\/product\/*/
// @include        /^https?:\/\/www.amazon.*\/exec\/obidos\/ASIN\/*/
// @include        /^https?:\/\/www.amazon.*\/o\/ASIN\/*/
// @version 0.0.1.20140518104255
// ==/UserScript==
(function(doc) {
    // ASIN.0 in kindle store
    var asin = doc.getElementById("ASIN") || doc.getElementsByName("ASIN.0")[0];
    if (asin && asin.value) {
        history.replaceState(null, "Amazon URL Cleaner", "/dp/" + asin.value + "/");
    }
})(document);

Not a complete solution, but it helps...
 
Curious if my suggestion is something that can or can't be done on this forum and if it can, are there any plans to implement it or not? Just wondering if I should look forward to it happening or resign myself to overly long and obtrusive Amazon links :) Thanks.
 
awesome idea!

dunno how to cleanly implement it!

canonical concise URL format ftw
 
Back
Top