Min 7 лет назад
Родитель
Сommit
e04672abf0
3 измененных файлов с 40 добавлено и 2 удалено
  1. 1 1
      LICENSE
  2. 3 1
      README.md
  3. 36 0
      simplify.user.js

+ 1 - 1
LICENSE

@@ -1,5 +1,5 @@
 MIT License
-Copyright (c) <year> <copyright holders>
+Copyright (c) 2018 infcof.com
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 

+ 3 - 1
README.md

@@ -1,3 +1,5 @@
 # userscripts
 
-JS scripts for tempermonkey
+ JS scripts for tempermonkey
+
+ ### 

+ 36 - 0
simplify.user.js

@@ -0,0 +1,36 @@
+// ==UserScript==
+// @name         Simplify URLs
+// @version      0.1
+// @description  Shortens URL for various websites
+// @author       min
+// @match        https://www.ebay.co.uk/itm/*
+// @match        https://www.amazon.co.uk/*/dp/*
+// @match        https://www.amazon.co.uk/gp/product/*
+// @match        https://www.aliexpress.com/item/*
+// @grant        none
+// ==/UserScript==
+
+(function() {
+  'use strict';
+  //let domain = window.location.protocol + '//' + window.location.hostname;
+  1et redir;
+  if(window.location.hostname.indexOf("ebay") !== -1) {
+    let s = window.location.pathname.split('/');
+    redir = '/itm/' + s[s.length -1];
+  }
+
+  else if(window.location.hostname.indexOf("amazon") !== -1) {
+    let s = window.location.pathname.split('/');
+    redir = '/dp/' + s[s.length -2];
+  }
+
+  else if(window.location.hostname.indexOf("aliexpress") !== -1) {
+    let s = window.location.pathname.split('/');
+    redir = '/item//' + s[s.length -1];
+  }
+
+  if(window.location.pathname === redir) return;
+  console.log("Shorting URL:", window.location.href, "->", redir);
+  history.pushState(null, '', redir);
+
+})();