How to Reload Google Chrome Tab from Terminal

windows chrome refresh tab 0(or current tab) via command line

I use this myself: (I wrote is quickly as it was only for personal use). With a lot of clean up you might be able to get what you want. See https://developers.google.com/chrome-developer-tools/docs/remote-debugging

import urllib2
import urllib
import os
import subprocess
import json

from websocket import create_connection

def refresh_page(url):
data = json.load(urllib2.urlopen('http://localhost:9222/json'))

found_page = False
for page in data:
if page['url'].lower() == url.lower():
found_page = True
websocketURL = page['webSocketDebuggerUrl']
ws = create_connection(websocketURL)

obj = { "id": 0,
"method": "Page.reload",
"params":
{
"ignoreCache": True,
"scriptToEvaluateOnLoad": ""
}
}

dev_request = json.dumps(obj)
ws.send(dev_request)
result = ws.recv()
ws.close()
if not found_page:
raise Exception("No pageFound")

def open_or_refresh(file_name):
file_name = "".join ( [f if f in r'\/:*?"<>|' else urllib.quote(f) for f in file_name] )
file_name = 'file:///' + file_name.replace('\\', '/')
file_name = file_name.encode('ascii', 'ignore')
try:
refresh_page(file_name)
except:
cmd = (r'"%(LOCALAPPDATA)s\Google\Chrome\Application\chrome.exe"'%os.environ
+ r' --remote-debugging-port=9222 "%s"' % file_name)
subprocess.Popen(cmd)

open_or_refresh(r"C:\test.html")
open_or_refresh(r"C:\test.html")

How to reload/refresh a web page without leaving my web development IDE?

In Windows XP, this should work:

  • Create a VBS file called refresh.vbs:

    Set WshShell = WScript.CreateObject("WScript.Shell") 
    WshShell.AppActivate("Firefox")
    WshShell.SendKeys "{F5}"
    WshShell.AppActivate("TextPad")
  • Create a shortcut to this file on your desktop.

  • Right-click the shortcut icon and go to Properties.

    • In the General tab, click on the Change button next to "Opens with".
      Browse to C:\WINDOWS\system32\cscript.exe
      Select Microsoft Console Based Script Host.

    • In the Shortcut tab, enter a Shortcut key e.g CTRL + ALT + R. In the Run dropdown, select Minimised.

Now, when you hit CTRL + ALT + R, it will refresh the current tab in Firefox.

How do I open a file with Chrome from the command line?

Doing some search for chromium you could do it like chromium-browser path|file.

How can I open Google Chrome from the terminal with the URL localhost:3000?

Have you tried?

google-chrome http://localhost:3000

auto-reload html file with a browser via terminal command

If there is already a tab for foo.html, open foo.html should focus that tab in Safari. For Chrome, you might use something like this:

set u to "http://t.co/"
tell application "Google Chrome"
repeat with w in windows
set i to 0
repeat with t in tabs of w
set i to i + 1
if URL of t is u then
set active tab index of w to i
set index of w to 1
tell t to reload
activate
return
end if
end repeat
end repeat
open location u
activate
end tell

I have just assigned ⌘R to open "$TM_FILEPATH" -a Safari in the text.html scope in TextMate. I have also enabled saving documents when switching to another application, so it basically does the last three steps of the edit-save-switch application-refresh cycle.

Other options:

  • http://livereload.com
  • http://brettterpstra.com/2011/03/07/watch-for-file-changes-and-refresh-your-browser-automatically

How do I auto-reload a Chrome extension I'm developing?

You can use "Extensions Reloader" for Chrome:

Reloads all unpacked extensions using the extension's toolbar button or by browsing to "http://reload.extensions"

If you've ever developed a Chrome extension, you might have wanted to
automate the process of reloading your unpacked extension without the
need of going through the extensions page.

"Extensions Reloader" allows you to reload all unpacked extensions
using 2 ways:

1 - The extension's toolbar button.

2 - Browsing to "http://reload.extensions".

The toolbar icon will reload unpacked extensions using a single click.

The "reload by browsing" is intended for automating the reload process
using "post build" scripts - just add a browse to
"http://reload.extensions" using Chrome to your script, and you'll
have a refreshed Chrome window.

Update: As of January 14, 2015, the extension is open-sourced and available on GitHub.



Related Topics



Leave a reply



Submit