• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

kritollm/chrome-extension-api-for-safari-and-firefox: Create extensions for Chro ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

kritollm/chrome-extension-api-for-safari-and-firefox

开源软件地址:

https://github.com/kritollm/chrome-extension-api-for-safari-and-firefox

开源编程语言:

JavaScript 100.0%

开源软件介绍:

Chrome extension API for Safari and Firefox

With these two API's you can make Chrome extensions and use the same code and manifest in Safari and Firefox. If you have more than one '*' in your urls in the manifest Firefox or Safari (I don't remember) fails.

The manifest parser for Firefox is the same as main.js.

Safari:

  • Build an extension with the extension builder and set the web_accessible_resources the same as in your manifest.json. Maybe the permissions can be parsed from manifest.json, but for now you have to do it manually. You can also edit the info.plist:
<key>Permissions</key>
	<dict>
		<key>Website Access</key>
		<dict>
			<key>Include Secure Pages</key>
			<true/>
			<key>Level</key>
			<string>All</string>
		</dict>
	</dict>
  • Copy the chromeAPISafari directory, your js directory and the manifest.json to your Safari extension.

  • Add the chromeAPISafari to extensionName.html, it should look like this:

<!DOCTYPE html>
<html>
<head>
    <title>Hello World</title>
    <script type="text/javascript" src="chromeAPISafari/chromeManifestSimulatorSafari.js"></script>
    <script type="text/javascript" src="chromeAPISafari/chromeAPIForSafari.js"></script>
    <script type="text/javascript" src="js/background.js"></script>
</head>
<body>Hello World!</body>
</html>

If you inject css with fonts you need to use .ttf instead of .wof If you have only used Chrome Api's defined in the ChromeAPIForSafari.js, it should work.

Firefox:

ChromeApiForFirefox have a hack to follow a tab which is moved between windows. I found no better solution, and the solution does not work in FirefoxDeveloperEdition where you eventually lose the tab reference. For some strange reason, tab id change when moving tab to another window.

I used the cfx init, but I see that tool is deprecated. But I think you can do jpm init, choose the chromeApiForSafari/chromeManifestSimulatorFirefox.js as your entry point. Make a data directory, then copy all your files (js directory, html, img..) into the data directory.

If you inject css with fonts you need to use dataURL instead. If you have only used Chrome Api's defined in the ChromeAPIForFirefox.js, it should work.

Things I want to add:

I will include a sample later.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap