simplify.user.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // ==UserScript==
  2. // @name Simplify URLs
  3. // @version 0.2
  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. // @match https://autoplius.lt/skelbimai/*.html
  13. // @match https://autogidas.lt/skelbimas/*.html
  14. // @match https://skelbiu.lt/skelbimai/*.html
  15. // @match https://www.fasttech.com/products/*
  16. // @grant none
  17. // ==/UserScript==
  18. (function() {
  19. 'use strict';
  20. //let domain = window.location.protocol + '//' + window.location.hostname;
  21. let redir;
  22. if(window.location.hostname.indexOf("ebay") !== -1) {
  23. let s = window.location.pathname.split('/');
  24. redir = '/itm/' + s[s.length -1] + '?nordt=true';
  25. }
  26. else if(window.location.hostname.indexOf("amazon") !== -1) {
  27. let s = window.location.pathname.split('/');
  28. redir = '/dp/' + s[s.length -2];
  29. }
  30. else if(window.location.hostname.indexOf("aliexpress") !== -1) {
  31. let s = window.location.pathname.split('/');
  32. redir = '/item//' + s[s.length -1];
  33. }
  34. else if(window.location.hostname.indexOf("fasttech") !== -1) {
  35. let s = window.location.pathname.split('/');
  36. let d = s[s.length -1].split('-');
  37. redir = '/products/' + d[0];
  38. }
  39. else if(window.location.hostname.indexOf("autoplius.lt") !== -1 ||
  40. window.location.hostname.indexOf("autogidas.lt") !== -1) {
  41. let s = window.location.pathname.split('-');
  42. let d = window.location.pathname.split('/');
  43. redir = '/'+ d[1] + '/-' + s[s.length -1];
  44. }
  45. else if(window.location.hostname.indexOf("skelbiu.lt") !== -1) {
  46. let s = window.location.pathname.split('-');
  47. redir = '/skelbimai/' + s[s.length -1];
  48. }
  49. if(window.location.pathname === redir) return;
  50. console.log("Shorting URL:", window.location.href, "->", redir);
  51. history.pushState(null, '', redir);
  52. })();