Skip to content

Instantly share code, notes, and snippets.

@generalov
Created March 26, 2014 08:20
Show Gist options
  • Save generalov/9778791 to your computer and use it in GitHub Desktop.
Save generalov/9778791 to your computer and use it in GitHub Desktop.
Reload tab in Google Chrome with given url.
// Don't forget to run the shell
// google-chrome --remote-debugging-port=9222
var url = 'http://localhost:9000/';
function startswith(str, prefix) {
return str.substring(0, prefix.length) === prefix;
}
var Chrome = require('chrome-remote-interface');
Chrome({
chooseTab: function(tabs) {
for(var i=0, c=tabs.length; i<c; i++) {
if (startswith(tabs[i].url, url)) {
return i;
}
}
return 0;
}
},
function(chrome) {
chrome.Page.reload();
chrome.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment