Created
September 11, 2017 09:12
-
-
Save Timmmm/6a376e9e4018441aab23e33abc9237c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AppleScript to reload a Chrome tab. | |
function run(argv) { | |
if (argv.length !== 1) { | |
console.log("Please supply a (partial) URL to reload"); | |
return; | |
} | |
console.log("Trying to reload: " + argv[0]); | |
let a = Application("Google Chrome"); | |
for (let i = 0; i < a.windows.length; i++) { | |
let win = a.windows[i]; | |
for (let j = 0; j < win.tabs.length; j++) { | |
let tab = win.tabs[j]; | |
if (tab.url().startsWith("file://") && tab.url().endsWith(argv[0])) { | |
console.log("Reloading URL: " + tab.url()); | |
tab.reload(); | |
return; | |
} | |
} | |
} | |
console.log("Tab not found."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment