본문 바로가기

프로그래밍/코드 조각

자바스크립트로 UA 변경하기


var _newUA = navigator.userAgent.replace(/ ?Swing\/[0-9.]*/, '');

Object.defineProperty(window.navigator, "userAgent", {

  get: function() {return _newUA}

});


// "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 Swing/2.3.0.0"

함수 호출 후

// "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36"