5

Is it possible to spoof the user agent using a Safari extension? I know that Safari itself is able to spoof using the Develop menu item, but it's too limited for me.

As far as I know, Safari extensions use 'start' and 'end' scripts, but both are executed after the document has been loaded, so I can't use those scripts to change the user agent via JavaScript.

I'm not too sure about this, only started looking into extensions today, so maybe someone has another idea?

Rits
  • 5,105
  • 4
  • 42
  • 53

2 Answers2

1

If you just looking for a way to quickly change between User Agents in Safari, you might beable to use Applescript UI Script. Basically it can simulate almost any user interface click/type, which would allow fairly quick changing of User Agents.

Kendall Hopkins
  • 43,213
  • 17
  • 66
  • 89
1

If you go the AppleScript UI Scripting route, as mentioned by Kendal, you can change the User Agent by the name they shown on Safari’s menu:

tell application "Safari" to activate
tell application "System Events"
    tell process "Safari"
        click menu item "Safari — iOS 10 — iPad" of menu "User Agent" of menu item "User Agent" of menu "Develop" of menu bar item "Develop" of menu bar 1
    end tell
end tell
Community
  • 1
  • 1
user137369
  • 5,219
  • 5
  • 31
  • 54