简化 Amazon 的 URL

此脚本将亚马逊网址替换为简单的格式:https://www.amazon.*/dp/[ASIN]

  1. // ==UserScript==
  2. // @name Simplify Amazon URLs
  3. // @name:ja AmazonのURLをシンプルにする
  4. // @name:es Simplificar las URL de Amazon
  5. // @name:zh-CN 简化 Amazon 的 URL
  6. // @namespace https://x.com/mana2hoshi/
  7. // @version 1.0
  8. // @description This script replaces Amazon URLs with a simple format: https://www.amazon.*/dp/[ASIN]
  9. // @description:ja このスクリプトはAmazonのURLを https://www.amazon.*/dp/ [ASIN]というシンプルなものに置き換えます。
  10. // @description:es Este script reemplaza las URL de Amazon con un formato simple: https://www.amazon.*/dp/[ASIN]
  11. // @description:zh-cn 此脚本将亚马逊网址替换为简单的格式:https://www.amazon.*/dp/[ASIN]
  12. // @license MIT
  13. // @author Manatsu
  14. // @match https://www.amazon.com/*/dp/*
  15. // @match https://www.amzn.com/*/dp/*
  16. // @match https://www.amazon.co.uk/*/dp/*
  17. // @match https://www.amazon.de/*/dp/*
  18. // @match https://www.amazon.fr/*/dp/*
  19. // @match https://www.amazon.it/*/dp/*
  20. // @match https://www.amazon.ca/*/dp/*
  21. // @match https://www.amazon.com.mx/*/dp/*
  22. // @match https://www.amazon.es/*/dp/*
  23. // @match https://www.amazon.co.jp/*/dp/*
  24. // @match https://www.amazon.in/*/dp/*
  25. // @match https://www.amazon.com.br/*/dp/*
  26. // @match https://www.amazon.nl/*/dp/*
  27. // @match https://www.amazon.com.au/*/dp/*
  28. // @match https://www.amazon.ae/*/dp/*
  29. // @match https://www.amazon.eg/*/dp/*
  30. // @match https://www.amazon.pl/*/dp/*
  31. // @match https://www.amazon.se/*/dp/*
  32. // @match https://www.amazon.sg/*/dp/*
  33. // @match https://www.amazon.com.tr/*/dp/*
  34. // @match https://www.amazon.cn/*/dp/*
  35. // @match https://www.amazon.sa/*/dp/*
  36. // @match https://www.amazon.com.be/*/dp/*
  37. // @grant none
  38. // ==/UserScript==
  39.  
  40. (function() {
  41. 'use strict';
  42.  
  43. // ページのURLを取得
  44. var currentUrl = window.location.href;
  45.  
  46. // 正規表現を使用してASINを抽出
  47. var asinMatch = currentUrl.match(/\/dp\/([A-Za-z0-9]+)/);
  48.  
  49. if (asinMatch && asinMatch[1]) {
  50. // ASINを取得
  51. var asin = asinMatch[1];
  52.  
  53. // Amazonの国別ドメインを取得
  54. var amazonDomainMatch = currentUrl.match(/https:\/\/www\.amazon\.(.*?)\//);
  55. if (amazonDomainMatch && amazonDomainMatch[1]) {
  56. var amazonDomain = amazonDomainMatch[1];
  57.  
  58. // 新しいURLを生成
  59. var newUrl = 'https://www.amazon.' + amazonDomain + '/dp/' + asin;
  60.  
  61. // 新しいURLにリダイレクト
  62. window.location.href = newUrl;
  63. }
  64. }
  65. })();