Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

short url script but for eBay & ETSY ?

About: Amazon short URL
edited November 14 in Script Discussions IE

Hi! Congrats for this must-have script.
Are you able to create one for eBay & ETSY too ?

Only this workaround is available so far…

eBay copy short url button
https://greasyfork.org/fr/scripts/17528-ebay-copy-short-url-button

All the best!

Comments

  • edited December 7 Firefox

    Hi Freshhh,

    sorry for the delay. Just quickly made those for you, so they are not bulletproof. But should work. Let me know.

    Try this for Ebay:

    // ==UserScript==
    // @name         eBay short url
    // @namespace    graphen
    // @version      1.2.0
    // @description  Replaces long url by short url.
    // @author       Ariel Jannai, graphen
    // @include      /^https:\/\/www\.(be(fr|nl)\.)?ebay\.(at|ca|cn|vn|ie|it|nl|ph|pl|es|ch|de|fr|be|co\.(uk|th)|com(\.(au|hk|my|sg|tw))?)\/itm\/.*/
    // @run-at       document-end
    // @icon         https://cdn4.iconfinder.com/data/icons/flat-brand-logo-2/512/ebay-128.png
    // @grant        none
    // @license      MIT
    // ==/UserScript==
    
    /* jshint esversion: 6 */
    (function(){
        'use strict';
    
        function tryShortUrl(url) {
            var urlPattern = /(be(fr|nl)\.)?ebay\.(at|ca|cn|vn|ie|it|nl|ph|pl|es|ch|de|fr|be|co\.(uk|th)|com(\.(au|hk|my|sg|tw))?)\/itm\//;
    
            if(urlPattern.test(url)) {
                var itmId = url.match(/\/(\d{12})(\?|$)/)[1];
                return 'https://www.' + urlPattern.exec(url)[0] + itmId;
            } else {
                return url;
            }
        }
    
        var url = String(window.location.href);
        history.replaceState(null, 'Shortened Ebay URL', tryShortUrl(url));
    
    })();
    

    Try this for Etsy:

    // ==UserScript==
    // @name         Etsy short url
    // @namespace    graphen
    // @version      1.1.0
    // @description  Replaces long url by short url.
    // @author       graphen
    // @include      https://www.etsy.com/*
    // @run-at       document-end
    // @icon         https://www.etsy.com/images/favicon.ico
    // @grant        none
    // @license      MIT
    // ==/UserScript==
    
    /* jshint esversion: 6 */
    (function(){
        'use strict';
    
        var itemId = document.getElementById("listing-image").getAttribute("data-palette-listing-id");
    
        if(itemId) {
            history.replaceState(null, 'Shortened Etsy URL', "https://www.etsy.com/listing/" + itemId);
        }
    
    })();
    

    Greetings,
    Graphen

  • Hi!

    Thanks a lot for giving it a try.
    I really appreciate it a lot because those long eBay url are very annoying.

    Unfortunately it does nothing.
    Tested with eBay.com without luck, the link remains the same.

    Could you please test and try to fix it?

    And if it works please kindly add support for :

    www.befr.ebay.be
    www.benl.ebay.be
    www.eBay.fr

    Thanks!

    Best,

    Freshhh

  • Bummer... Same for Etsy, it does nothing… weird
    I wonder how it can works for you and not for me?

  • I don't know.
    Works perfectly for me. Firefox 63.0.3, latest Tampermonkey, Windows 10.

    Modified ebay to support the three domains you mentioned.

  • edited December 7 IE

    Fantastic, the new eBay short URL universal script works wonders!
    Thank you so much, this will definitely be a lifesaving script for all users.

    Just in case you don't mind adding all domains here is a full list:
    http://blog.linnworks.com/international-ebay-sites-list


    About the ETSY script there is a little bug, currently shortened URL are transformed like this:

    https://www.etsy.com/123456789/

    but it must be formatted like this:

    https://www.etsy.com/listing/123456789/

    otherwise if you refresh the page there is a 404 not found error!

  • Thanks for the hints, both fixed.
    I put both scripts online now.

    Etsy: https://greasyfork.org/scripts/375272
    Ebay: https://greasyfork.org/scripts/375273

  • Tested and adopted. B)
    BIG THANKS ! !

Sign In or Register to comment.