我想为我的chrome扩展重新加载每次我保存在扩展文件夹中的文件,而不必显式点击“重新加载”在chrome://extensions/。这可能吗?
编辑:我知道我可以更新Chrome重新加载扩展的间隔,这是一个中途的解决方案,但我宁愿让我的编辑器(emacs或textmate)触发保存重新加载或要求Chrome监控目录的变化。
我想为我的chrome扩展重新加载每次我保存在扩展文件夹中的文件,而不必显式点击“重新加载”在chrome://extensions/。这可能吗?
编辑:我知道我可以更新Chrome重新加载扩展的间隔,这是一个中途的解决方案,但我宁愿让我的编辑器(emacs或textmate)触发保存重新加载或要求Chrome监控目录的变化。
当前回答
如果你有一台Mac,最简单的方法就是使用Alfred App!
只需使用Powerpack获取Alfred App,然后添加下面链接中提供的工作流,并自定义你想要的热键(我喜欢使用⌘+ + R)。
现在,每次你使用热键,谷歌Chrome浏览器将重新加载,无论你在那个时刻的应用程序。
如果你想使用其他浏览器,打开AppleScript在阿尔弗雷德首选工作流程和替换“谷歌Chrome”与“Firefox”,“Safari”,…
我还将在这里显示在ReloadChrome中使用的/usr/bin/osascript脚本的内容。Alfredworkflow文件,这样你就可以看到它在做什么。
tell application "Google Chrome"
activate
delay 0.5
tell application "System Events" to keystroke "r" using command down
delay 0.5
tell application "System Events" to keystroke tab using command down
end tell
工作流文件为ReloadChrome.alfredworkflow。
其他回答
感谢@GmonC和@Arik和一些空闲时间,我设法让它工作。我必须更改两个文件才能使其工作。
(1)为该应用程序安装LiveReload和Chrome扩展。 这将在文件更改时调用一些脚本。
打开<LiveReloadInstallDir>\ wrapped \backend\res\livereload.js
(3)将509行改为
This.window.location.href = "http://reload.extensions";
(4)现在安装另一个扩展Extensions Reloader,它有有用的链接处理程序,重新加载所有的开发扩展导航到“http://reload.extensions”
现在以这种方式更改扩展的background.min.js
if ((d.installType = = "发展")(&& d.enabled = = true) && (d.name != Reloader扩展”))
替换为
if((d.installType=="development")&&(d.enabled==true)&&(d.name!="Extensions Reloader")&&(d.name!="LiveReload"))
打开LiveReload应用程序,隐藏扩展重新加载按钮,并通过单击工具栏中的按钮激活LiveReload扩展,您现在将重新加载页面和每个文件更改扩展,同时使用所有其他好东西从LiveReload (css重新加载,图像重新加载等)
唯一不好的是,你将不得不重复在每次扩展更新上更改脚本的过程。为避免更新,请将扩展添加为未打包的扩展。
当我有更多的时间来处理这个时,我可能会创建一个扩展,消除对这两个扩展的需求。
在那之前,我正在做我的扩展Projext Axeman
作者推荐该webpack插件的下一个版本:https://github.com/rubenspgcavalcante/webpack-extension-reloader。这对我来说很有效。
是的,你可以间接地做!这是我的解决方案。
在manifest.json
{
"name": "",
"version": "1.0.0",
"description": "",
"content_scripts":[{
"run_at":"document_end",
"matches":["http://*/*"],
"js":["/scripts/inject.js"]
}]
}
在inject.js
(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = 'Your_Scripts';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(script, s);
})();
注入的脚本可以从任何位置注入其他脚本。
这种技术的另一个好处是你可以忽略孤立世界的限制。参见内容脚本执行环境
你可以使用Chrome的“Extensions Reloader”:
Reloads all unpacked extensions using the extension's toolbar button or by browsing to "http://reload.extensions" If you've ever developed a Chrome extension, you might have wanted to automate the process of reloading your unpacked extension without the need of going through the extensions page. "Extensions Reloader" allows you to reload all unpacked extensions using 2 ways: 1 - The extension's toolbar button. 2 - Browsing to "http://reload.extensions". The toolbar icon will reload unpacked extensions using a single click. The "reload by browsing" is intended for automating the reload process using "post build" scripts - just add a browse to "http://reload.extensions" using Chrome to your script, and you'll have a refreshed Chrome window.
更新:截至2015年1月14日,扩展是开源的,可在GitHub上使用。
刚刚发现了一个新的基于grunt的项目,它提供了引导,脚手架,一些自动预处理功能,以及自动重新加载(不需要交互)。
从Websecurify引导您的Chrome扩展