mobile-detect.js 795 B

12345678910111213141516171819202122
  1. (function(win) {
  2. var orgLink = win.location.href
  3. var newLink = ''
  4. if (orgLink.indexOf('&mobile=true') != -1) {
  5. Object.defineProperty(navigator, 'userAgent', {
  6. value: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
  7. writable: false
  8. })
  9. }
  10. else if (/iPhone|iPad|Android/i.test(win.navigator.userAgent)) {
  11. if (orgLink.indexOf('pc.html') !== -1) {
  12. newLink = orgLink.replace('pc.html', 'mobile.html')
  13. }
  14. } else {
  15. if (orgLink.indexOf('mobile.html') !== -1) {
  16. newLink = orgLink.replace('mobile.html', 'pc.html')
  17. }
  18. }
  19. if (newLink) {
  20. win.location.href = newLink
  21. }
  22. }(window))