移除虾皮追踪器

高效的清理虾皮商品网址

  1. // ==UserScript==
  2. // @name Remove shopee tracker
  3. // @name:zh-TW 移除蝦皮追蹤器
  4. // @name:zh-CN 移除虾皮追踪器
  5. // @namespace https://gf.qytechs.cn
  6. // @version 0.0.5
  7. // @description Efficiently clean Shopee product URLs.
  8. // @description:zh-TW 高效的清理蝦皮商品網址
  9. // @description:zh-CN 高效的清理虾皮商品网址
  10. // @author Pixmi
  11. // @match *://shopee.tw/*
  12. // @match *://shopee.ph/*
  13. // @match *://shopee.sg/*
  14. // @match *://shopee.com.my/*
  15. // @icon https://icons.duckduckgo.com/ip2/shopee.com.ico
  16. // @grant none
  17. // @license GPL-3.0
  18. // @run-at document-body
  19. // ==/UserScript==
  20.  
  21. (function() {
  22. 'use strict';
  23.  
  24. const reg = new RegExp(/\-i\.([\d]+)\.([\d]+)/);
  25. const cleanURL = (url) => {
  26. const match = url.match(reg);
  27. if (!match) return url;
  28. return `/product/${match[1]}/${match[2]}`;
  29. };
  30. if (reg.test(window.location.href)) {
  31. window.location.replace(`${window.location.origin}${cleanURL(window.location.href)}`);
  32. }
  33. const originalPushState = history.pushState;
  34. const originalReplaceState = history.replaceState;
  35.  
  36. history.pushState = function(state, title, url) {
  37. if (url) { url = cleanURL(url); }
  38. return originalPushState.call(this, state, title, url);
  39. };
  40.  
  41. history.replaceState = function(state, title, url) {
  42. if (url) { url = cleanURL(url); }
  43. return originalReplaceState.call(this, state, title, url);
  44. };
  45. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址