Spoof user agent bookmarklet

Opens the current web page in a new tab with the user agent of your choice. Doesn't work on every site (ex. DuckDuckGo) and stops working as soon as you navigate away from the page. Some sites use other detection methods so they still see the real user agent. Tested to work on iOS browsers and macOS Safari, but failed to do any spoofing at all on macOS Chrome.


javascript:(function(){ _ua = prompt('Enter a user agent string', `Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.3`); if (! _ua) { throw '' }; _xhr = new XMLHttpRequest(); _xhr.open('GET', document.location, false); _xhr.setRequestHeader('User-Agent', _ua); _xhr.onreadystatechange = function() { if (_xhr.readyState == 4 && _xhr.status == 200) { return } }; _xhr.send(); _win = window.open('about:blank', '_blank'); _win.document.write(_xhr.responseText) })() /*www.no-op.co*/