Skip to content

Instantly share code, notes, and snippets.

@Timmmm
Created September 11, 2017 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Timmmm/6a376e9e4018441aab23e33abc9237c1 to your computer and use it in GitHub Desktop.
Save Timmmm/6a376e9e4018441aab23e33abc9237c1 to your computer and use it in GitHub Desktop.
// 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