simplify.user.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // ==UserScript==
  2. // @name Simplify URLs
  3. // @version 0.1
  4. // @description Shortens URL for various websites
  5. // @author min
  6. // @match https://www.ebay.co.uk/itm/*
  7. // @match https://www.amazon.co.uk/*/dp/*
  8. // @match https://www.amazon.co.uk/gp/product/*
  9. // @match https://www.aliexpress.com/item/*
  10. // @grant none
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14. //let domain = window.location.protocol + '//' + window.location.hostname;
  15. 1et redir;
  16. if(window.location.hostname.indexOf("ebay") !== -1) {
  17. let s = window.location.pathname.split('/');
  18. redir = '/itm/' + s[s.length -1];
  19. }
  20. else if(window.location.hostname.indexOf("amazon") !== -1) {
  21. let s = window.location.pathname.split('/');
  22. redir = '/dp/' + s[s.length -2];
  23. }
  24. else if(window.location.hostname.indexOf("aliexpress") !== -1) {
  25. let s = window.location.pathname.split('/');
  26. redir = '/item//' + s[s.length -1];
  27. }
  28. if(window.location.pathname === redir) return;
  29. console.log("Shorting URL:", window.location.href, "->", redir);
  30. history.pushState(null, '', redir);
  31. })();