Skip to content

Instantly share code, notes, and snippets.

@perpetual-hydrofoil
Forked from generalov/chrome-open.js
Last active August 29, 2015 14:07
Show Gist options
  • Save perpetual-hydrofoil/061cbeca69c885c3634d to your computer and use it in GitHub Desktop.
Save perpetual-hydrofoil/061cbeca69c885c3634d to your computer and use it in GitHub Desktop.
// 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