mobile-detect.js 804 B

123456789101112131415161718192021
  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. } else if (/iPhone|iPad|Android/i.test(win.navigator.userAgent)) {
  10. if (orgLink.indexOf('pg.html') !== -1) {
  11. newLink = orgLink.replace('pg.html', 'mg.html')
  12. }
  13. } else {
  14. if (orgLink.indexOf('mg.html') !== -1) {
  15. newLink = orgLink.replace('mg.html', 'pg.html')
  16. }
  17. }
  18. if (newLink) {
  19. win.location.href = newLink
  20. }
  21. })(window)