simplify.user.js 1.3 KB

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