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
目前為
// ==UserScript==
// @name Etsy URl Cleaner
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @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
// @match https://www.etsy.com/listing/*
// @match https://www.etsy.com/shop/*
// @grant none
// @icon https://www.etsy.com/favicon.ico
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Get the current URL
var url = window.location.href;
// 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)
if (url.indexOf('?ref') !== -1 || url.indexOf('?click_key') !== -1 || url.indexOf('?ga_order') !== -1 || url.indexOf('?ref=simple-shop-header') !== -1) {
// Get the index of the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter that appears last in the URL
var index = Math.max(url.indexOf('?ref'), url.indexOf('?click_key'), url.indexOf('?ga_order'), url.indexOf('?ref=simple-shop-header'));
// Remove the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter and everything after it
url = url.substring(0, index);
// Update the URL without the ?ref, ?click_key, ?ga_order, or ?ref=simple-shop-header parameter
window.history.pushState({}, '', url);
}
})();