diff --git a/.sv/control/control.py b/.sv/control/control.py index a588831..216c6ae 100644 --- a/.sv/control/control.py +++ b/.sv/control/control.py @@ -80,6 +80,7 @@ def update(self, page): if not self._socket_url: # Might be empty in /json/list self._socket_url = page['webSocketDebuggerUrl'] + # For rpc information, see https://chromedevtools.github.io/devtools-protocol/ self.ensure_connected() def ensure_connected(self): @@ -93,6 +94,7 @@ def ensure_connected(self): return log("websocket connected") self._eventloop.register(self._fd, self.receive_rpc) + self.call_rpc("Network.enable") self.call_rpc("Page.enable") self.call_rpc("Runtime.enable") self.call_rpc("DOM.enable") @@ -190,10 +192,12 @@ def receive_rpc(self): traceback.print_exc() self.reset_connection() - def navigate(self, url, scripts): + def navigate(self, url, scripts, headers): self._loaded = False self._frames = {} self._scripts = scripts + self._headers = headers + self.call_rpc("Network.setExtraHTTPHeaders", headers=headers) self.call_rpc("Page.navigate", url=url) class Browser(object): @@ -229,10 +233,10 @@ def open(self, url): self._tab_by_id[id]= Tab(self._eventloop, page) self._tabs.append(id) - def navigate(self, idx, url, script): + def navigate(self, idx, url, script, headers): id = self.tabs[idx] - log("=== Navigate %s -> %s" % (id, url)) - self._tab_by_id[id].navigate(url, script) + log("=== Navigate %s -> %s (headers: %s)" % (id, url, headers)) + self._tab_by_id[id].navigate(url, script, headers) def switch_to(self, idx): id = self.tabs[idx] @@ -319,10 +323,16 @@ def load_config(self): with open(os.path.join(self._prefix, config['scripts']['asset_name'])) as s: scripts = Scripts(json.load(s)) + headers = {} + _headers = config['headers'] + if _headers: + for item in _headers: + headers[item['name']] = item['value'] + urls = config['urls'] if urls: self._urls = cycle([ - (item['duration'], item['url'], scripts) + (item['duration'], item['url'], scripts, headers) for item in urls if item['duration'] > 0 ]).next @@ -378,11 +388,11 @@ def ensure_two_tabs(self): return fixed def preload_next(self): - self._next_duration, url, scripts = self._config.next_item() + self._next_duration, url, scripts, headers = self._config.next_item() log("[browser-control] Loading %s in tab 1: next switch %d (in %ds)" % ( url, self._next_switch, self._next_switch - time.time() )) - self._browser.navigate(1, url, scripts) + self._browser.navigate(1, url, scripts, headers) self._preloading = True def tick(self): @@ -417,7 +427,7 @@ def tick(self): send_ib('root/fade:1') self._next_switch = now + self._next_duration self._preloading = False - self._browser.navigate(1, 'about:blank', Scripts([])) + self._browser.navigate(1, 'about:blank', Scripts([]), {}) config_json = os.path.join(os.environ['NODE_PATH'], 'config.json') if len(sys.argv) == 2: diff --git a/README.md b/README.md index 37255aa..bf09a22 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ thanks for the great work! This version is mentioned to support HTTP request headers. For example the `Authorization` header. +[![Import](https://cdn.infobeamer.com/s/img/import.png)](https://info-beamer.com/use?url=https://github.com/choeflake/infobeamer-fullscreen-browser-package.git) + +# Git LFS + +This repository uses Git LFS for the large filesystem overlay. See https://docs.github.com/en/repositories/working-with-files/managing-large-files/configuring-git-large-file-storage. + # Experimental browser for info-beamer hosted This package allows you to show webpages in a constant rotation. diff --git a/node.json b/node.json index 4159474..4b7eae3 100644 --- a/node.json +++ b/node.json @@ -53,6 +53,24 @@ { "title": "Advanced settings", "type": "section" + }, { + "title": "Which headers do you want to add?", + "name": "headers", + "type": "list", + "itemname": "Header", + "items": [{ + "title": "Header", + "ui_width": 3, + "name": "name", + "type": "string", + "default": "" + }, { + "title": "Value", + "ui_width": 9, + "name": "value", + "type": "string", + "default": "" + }] }, { "title": "Time Zone", "ui_width": 6, diff --git a/package.json b/package.json index 4165a01..eab2b72 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "Fullscreen Browser", + "name": "Fullscreen Browser+", "author": "info-beamer.com", - "version": "86", - "desc": "Chromium Browser packaged as an info-beamer hosted 'service'", + "version": "86.plus", + "desc": "Chromium Browser packaged as an info-beamer hosted 'service'. With support for custom request headers.", "runtime": { "transparent": true },