Amazon.com auto redirect mobile to desktop version

Automatically redirect from mobile version to desktop version of the page.

  1. // ==UserScript==
  2. // @id amazon.com_mobile2desktop
  3. // @name Amazon.com auto redirect mobile to desktop version
  4. // @version 1.3.2
  5. // @namespace V@no
  6. // @author V@no
  7. // @description Automatically redirect from mobile version to desktop version of the page.
  8. // @include http://amazon.com/*
  9. // @include http://www.amazon.com/*
  10. // @include https://amazon.com/*
  11. // @include https://www.amazon.com/*
  12. // @grant none
  13. // @run-at document-start
  14. // ==/UserScript==
  15.  
  16. //redirect mobile to desktop
  17. (function()
  18. {
  19. let log = console.log.bind(console);
  20. if (location.pathname.match(/^\/gp\/aw\//i))
  21. {
  22. window.location.replace(window.location.toString().replace(/^(https?:\/\/(www\.)?amazon\.com\/)gp\/aw\/(d\/)?(.*)/ig, "$1dp/$4"));
  23. }
  24. else
  25. {
  26. //redirect to charity amazon
  27. if (!location.hostname.match(/smile\.amazon\.com/i) && location.href.indexOf("signin") == -1)
  28. {
  29. let smile = window.location.toString().replace(/^(https?:\/\/)([^\/]+)\/(.*)/ig, "$1smile.amazon.com/$3");
  30. if (location.search.indexOf("pldnSite") == -1)
  31. {
  32. log("Redirecting to smile.amazon.com");
  33. window.location.replace(smile);
  34. }
  35. else
  36. {
  37. log("Can't redirect to smile.amazon.com due to pldnSite")
  38. }
  39. }
  40. }
  41. })();

QingJ © 2025

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