Auto redirect

手機版、電腦版網頁自動跳轉

  1. // ==UserScript==
  2. // @name Auto redirect
  3. // @description 手機版、電腦版網頁自動跳轉
  4. // @namespace 7ED70DC0-CD34-11E7-8C84-6590899BC43F
  5. // @match https://m.gamer.com.tw/*
  6. // @match https://m.facebook.com/*
  7. // @match https://m.591.com.tw/v2/rent/*
  8. // @match https://m.cosdna.com/*
  9. // @match https://m.momoshop.com.tw/*
  10. // @version 1.3.0
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14.  
  15. function toPC () {
  16. switch (location.hostname) {
  17. // 巴哈
  18. case 'm.gamer.com.tw':
  19. document.querySelector('.gtm-nav-backpc').click()
  20. break
  21. // FB
  22. case 'm.facebook.com':
  23. if (location.pathname === '/story.php') {
  24. location.href = 'https://www.facebook.com/' + location.search.match(/[?&]id=([^&]+)/)[1] + '/posts/' + location.search.match(/[?&]story_fbid=([^&]+)/)[1]
  25. } else {
  26. location.href = 'https://www' + location.href.slice(9)
  27. }
  28. break
  29. // 591
  30. case 'm.591.com.tw':
  31. location.href = 'https://rent.591.com.tw/rent-detail-' + location.pathname.split('/').pop().match(/\d+/)[0] + '.html'
  32. break
  33. // CosDNA
  34. case 'm.cosdna.com':
  35. location.host = 'cosdna.com'
  36. break
  37. // momo
  38. case 'm.momoshop.com.tw':
  39. switch (location.pathname) {
  40. case '/goods.momo':
  41. // https://m.momoshop.com.tw/goods.momo?i_code=7502072
  42. location.href = 'https://www.momoshop.com.tw/goods/GoodsDetail.jsp' + location.search
  43. break
  44. case '/search.momo':
  45. // https://m.momoshop.com.tw/search.momo?searchKeyword=防噪音耳塞&couponSeq=&cpName=&searchType=1&cateCode=-1&ent=k&_imgSH=fourCardStyle
  46. // 不能直接使用全部 location.search,會搜尋不到任何東西
  47. let searchKeyword = location.search.match(/[?&]searchKeyword=([^?&]+)/)[1]
  48. location.href = 'https://www.momoshop.com.tw/search/searchShop.jsp?keyword=' + searchKeyword
  49. break
  50. }
  51. break
  52. }
  53. }
  54.  
  55. function toMobile () {
  56.  
  57. }
  58.  
  59. if (navigator.userAgentData.mobile) {
  60. toMobile()
  61. } else {
  62. toPC()
  63. }

QingJ © 2025

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