Etsy URL Cleaner

Removes the ?ref, ?click_key, ?ga_order, and ?external query parameters from the URL of an Etsy listing page and removes the ?ref=simple-shop-header query parameter and everything after it from the URL of an Etsy shop page

目前为 2023-02-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Etsy URL Cleaner
  3. // @namespace https://greasyfork.org/en/scripts/456795-etsy-url-cleaner
  4. // @version 1.0.3
  5. // @description Removes the ?ref, ?click_key, ?ga_order, and ?external query parameters from the URL of an Etsy listing page and removes the ?ref=simple-shop-header query parameter and everything after it from the URL of an Etsy shop page
  6. // @match https://www.etsy.com/listing/*
  7. // @match https://www.etsy.com/shop/*
  8. // @match https://i.etsystatic.com/*
  9. // @grant none
  10. // @icon https://www.etsy.com/favicon.ico
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Get the current URL
  18. var url = window.location.href;
  19.  
  20. // Check if the URL contains the ?ref, ?click_key, or ?ga_order parameter (for listing pages) or the ?ref=simple-shop-header parameter (for shop pages)
  21. if (url.indexOf('?ref') !== -1 || url.indexOf('?click_key') !== -1 || url.indexOf('?ga_order') !== -1 || url.indexOf('?ref=simple-shop-header') !== -1) {
  22. // Get the index of the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter that appears last in the URL
  23. var index = Math.max(url.indexOf('?ref'), url.indexOf('?click_key'), url.indexOf('?ga_order'), url.indexOf('?ref=simple-shop-header'));
  24.  
  25. // Remove the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter and everything after it
  26. url = url.substring(0, index);
  27.  
  28. // Update the URL without the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter
  29. window.history.pushState({}, '', url);
  30. }
  31.  
  32. // Check if the URL already contains "/il_fullxfull"
  33. if (url.indexOf('/il_fullxfull') !== -1) {
  34. return;
  35. }
  36.  
  37. // Check if the URL contains "/il_"
  38. if (url.indexOf('/il_') !== -1) {
  39. // Get the index of the first dot after "/il_"
  40. var dotIndex = url.indexOf('.', url.indexOf('/il_'));
  41.  
  42. // Replace the content between "/il_" and the first dot after it with "fullxfull"
  43. url = url.substring(0, url.indexOf('/il_')) + '/il_fullxfull' + url.substring(dotIndex);
  44.  
  45. // Update the URL with the modified URL
  46. window.location.href = url;
  47. }
  48. })();
  49.