简体   繁体   English

Safari Extensions的单击安装

[英]One Click install for Safari Extensions

When a user downloads a plugin firefox (for example) the plugin installation begins as soon as the download has completed. 当用户下载插件firefox(例如)时,插件安装在下载完成后立即开始。

Is it possible to achieve the same thing in safari? 是否有可能在野生动物园中实现同样的目标? ie user clicks link to download plugin, once it has downloaded it automatically begins the installation. 即用户点击链接下载插件,一旦下载它自动开始安装。

I don't think this is possible to do on any other domain except extensions.apple.com . 除了extensions.apple.com之外,我不认为这可以在任何其他域上进行。

I've done some extensive testing on this and the safari.installExtension() method is only present if the domain matches extensions.apple.com (probably controlled by the browser, similar to how certain Chrome APIs only shows up inside of extensions themselves). 我已对此进行了一些广泛的测试,只有当域名与extensions.apple.com匹配时,才会出现safari.installExtension()方法(可能由浏览器控制,类似于某些Chrome API仅在扩展程序内部显示) 。

I tested this theory by going to the JS file itself and opening the JS console: https://extensions.apple.com/home/scripts/extensionInstall.js 我通过转到JS文件并打开JS控制台测试了这个理论: https//extensions.apple.com/home/scripts/extensionInstall.js

After that JS file has loaded, type typeof(safari.installExtension) in the JS console and it should return "function" . 加载JS文件后,在JS控制台中键入typeof(safari.installExtension) ,它应该返回"function" Notice that it exists on a non-HTML page, meaning it's being provided by the browser (since this script doesn't execute, nor has the code in it to provide this method). 请注意,它存在于非HTML页面上,这意味着它由浏览器提供(因为此脚本不执行,也没有提供此方法的代码)。

I tried doing this on other sites and it doesn't exist: "undefined" . 我尝试在其他网站上执行此操作但它不存在: "undefined"

I also had a crazy thought that it just needs extensions as the subdomain, so I tested it on http://extensions.joomla.org too, no dice. 我也有一个疯狂的想法,它只需要扩展作为子域,所以我也在http://extensions.joomla.org上测试它,没有骰子。 I can't seem to find an extensions sub-domain that's SSL though. 我似乎无法找到SSL的扩展子域。 That may work, but I seriously doubt it as the method appears to be regulated to only show up when on Apple's specific extensions sub-domain. 这可能有用,但我严重怀疑它,因为这种方法似乎只能在Apple的特定扩展子域上显示出来。

No solution for that here, but maybe this can help? 这里没有解决方案,但也许这有用吗?

In apple extension gallery at https://extensions.apple.com the extensions do install in one click, and i wanted to achieve the same in a website of mine, so i went and checked their JS source code. https://extensions.apple.com的苹果扩展库中,扩展程序只需单击即可安装,我想在我的网站中实现相同的功能,所以我去检查了他们的JS源代码。

A javascript file there defines a "ExtensionOneClick" Object ( https://extensions.apple.com/home/scripts/extensions.js ). 一个javascript文件定义了一个“ExtensionOneClick”对象( https://extensions.apple.com/home/scripts/extensions.js )。

A method is dedicated to installing extensions: 一种方法专用于安装扩展:

// href : path to the extension ".safariextz" file
// id   : com.whatever.myextension-<safaridevelopper10charsid>

safari.installExtension(id, href);

I tried to replicate this on my website, but i get "safari is undefined", so I guess a site specific hack in Safari is helping here? 我试图在我的网站上复制这个,但我得到“safari is undefined”,所以我猜Safari中的网站特定黑客在这里有帮助吗?

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

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