Created
March 26, 2014 08:20
-
-
Save generalov/9778791 to your computer and use it in GitHub Desktop.
Reload tab in Google Chrome with given url.
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
// 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