简体   繁体   English

欺骗用户代理的Safari扩展?

[英]Safari extension that spoofs user-agent?

Is it possible to spoof the user agent using a Safari extension? 是否可以使用Safari扩展程序欺骗用户代理? I know that Safari itself is able to spoof using the Develop menu item, but it's too limited for me. 我知道Safari本身可以使用“开发”菜单项进行欺骗,但是对我来说太有限了。

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. 据我所知,Safari扩展使用“开始”和“结束”脚本,但是两者均在文档加载执行,因此我无法使用这些脚本通过JavaScript更改用户代理。

I'm not too sure about this, only started looking into extensions today, so maybe someone has another idea? 我对此不太确定,只是今天才开始研究扩展,所以也许有人有其他想法?

If you just looking for a way to quickly change between User Agents in Safari, you might beable to use Applescript UI Script . 如果您只是想寻找一种在Safari中的用户代理之间快速切换的方法,则可以使用Applescript UI脚本 Basically it can simulate almost any user interface click/type, which would allow fairly quick changing of User Agents. 基本上,它可以模拟几乎所有用户界面的单击/类型,从而可以相当快速地更改用户代理。

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: Kendal所述 ,如果您使用AppleScript UI脚本编写路线,则可以通过在Safari菜单上显示的名称更改用户代理:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM