Skip to content

Instantly share code, notes, and snippets.

@kukiron
Forked from timdorr/ReloadPlugin.js
Created August 31, 2017 09:52
Show Gist options
  • Save kukiron/bc6083893ec044a6b63acf8a1a5f9c18 to your computer and use it in GitHub Desktop.
Save kukiron/bc6083893ec044a6b63acf8a1a5f9c18 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