mobile-detect.js 954 B

123456789101112131415161718192021222324
  1. (function(win) {
  2. var orgLink = win.location.href
  3. var newLink = ''
  4. if (orgLink.indexOf('&mobile=true') != -1) {
  5. if (orgLink.indexOf('pg.html') !== -1) {
  6. newLink = orgLink.replace('pg.html', 'mg.html')
  7. }
  8. Object.defineProperty(navigator, 'userAgent', {
  9. 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",
  10. writable: false
  11. })
  12. } else if (/iPhone|iPad|Android/i.test(win.navigator.userAgent) || orgLink.indexOf('&pad') != -1) {
  13. if (orgLink.indexOf('pg.html') !== -1) {
  14. newLink = orgLink.replace('pg.html', 'mg.html')
  15. }
  16. } else {
  17. if (orgLink.indexOf('mg.html') !== -1) {
  18. newLink = orgLink.replace('mg.html', 'pg.html')
  19. }
  20. }
  21. if (newLink) {
  22. win.location.href = newLink
  23. }
  24. }(window))