Skip to content

Instantly share code, notes, and snippets.

@timdorr
Created August 30, 2017 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timdorr/884f42608f36a61d66af74b6bb3d2285 to your computer and use it in GitHub Desktop.
Save timdorr/884f42608f36a61d66af74b6bb3d2285 to your computer and use it in GitHub Desktop.
Webpack Chrome Extension Page Reloader Plugin
tell application "Google Chrome"
set extensionURL to "chrome://extensions/"
set found to false
set theTabIndex to -1
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if theTab's URL starts with extensionURL then
set found to true
exit repeat
end if
end repeat
if found then
exit repeat
end if
end repeat
if found then
tell theTab to reload
else
tell window 1 to make new tab with properties {URL:extensionURL}
end if
end tell
function ReloadPlugin() {}
ReloadPlugin.prototype.apply = compiler => {
ReloadPlugin.watching = false
compiler.plugin('watch-run', (p, cb) => {
ReloadPlugin.watching = true
cb()
})
compiler.plugin('done', () => {
if (ReloadPlugin.watching) {
child.exec('osascript reload_extensions.scpt')
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment