Chris@0: command('set_js_errors', $enabled); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set a blacklist of urls that we are not supposed to load Chris@0: * @param array $blackList Chris@0: * @return bool Chris@0: */ Chris@0: public function urlBlacklist($blackList) { Chris@0: return $this->command('set_url_blacklist', $blackList); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set the debug mode on the browser Chris@0: * @param bool $enable Chris@0: * @return bool Chris@0: */ Chris@0: public function debug($enable = false) { Chris@0: $this->debug = $enable; Chris@0: return $this->command('set_debug', $this->debug); Chris@0: } Chris@0: Chris@12: /** Chris@12: * Set the timeout after which any resource requested will stop Chris@12: * trying and proceed with other parts of the page Chris@12: * @param int $resourceTimeout Chris@12: * @return bool Chris@12: */ Chris@12: public function resourceTimeout($resourceTimeout) { Chris@12: return $this->command('set_resource_timeout', $resourceTimeout); Chris@12: } Chris@12: Chris@12: /** Chris@12: * Sets or unsets web proxy. Chris@12: * Chris@12: * @param string|false $proxy proxy url formatted as '(http|socks5)://[username:password@]host:port', or false to unset Chris@12: * @return bool Chris@12: * @throws \UnexpectedValueException when the proxy url is invalid Chris@12: */ Chris@12: public function setProxy($proxy) Chris@12: { Chris@12: $args = array('set_proxy'); Chris@12: if ($proxy !== false) Chris@12: { Chris@12: if (preg_match('~^(http|socks5)://(?:([^:@/]*?):([^:@/]*?)@)?([^:@/]+):(\d+)$~', $proxy, $components)) Chris@12: { Chris@12: array_push($args, $components[4], intval($components[5], 10), $components[1]); Chris@12: if (strlen($components[2]) || strlen($components[3])) Chris@12: { Chris@12: array_push($args, urldecode($components[2]), urldecode($components[3])); Chris@12: } Chris@12: } Chris@12: else Chris@12: { Chris@12: throw new \UnexpectedValueException('Invalid proxy url ' . $proxy); Chris@12: } Chris@12: } Chris@12: return call_user_func_array(array($this, 'command'), $args); Chris@12: } Chris@0: }