Etsy URl Cleaner

Removes the ?ref, ?click_key, and ?ga_order 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

当前为 2022-12-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Etsy URl Cleaner
  3. // @namespace https://greasyfork.org/en/scripts/456795-etsy-url-cleaner
  4. // @version 1.0.1
  5. // @description Removes the ?ref, ?click_key, and ?ga_order 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. // @grant none
  9. // @icon https://www.etsy.com/favicon.ico
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Get the current URL
  17. var url = window.location.href;
  18.  
  19. // 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)
  20. if (url.indexOf('?ref') !== -1 || url.indexOf('?click_key') !== -1 || url.indexOf('?ga_order') !== -1 || url.indexOf('?ref=simple-shop-header') !== -1) {
  21. // Get the index of the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter that appears last in the URL
  22. var index = Math.max(url.indexOf('?ref'), url.indexOf('?click_key'), url.indexOf('?ga_order'), url.indexOf('?ref=simple-shop-header'));
  23.  
  24. // Remove the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter and everything after it
  25. url = url.substring(0, index);
  26.  
  27. // Update the URL without the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter
  28. window.history.pushState({}, '', url);
  29. }
  30. })();