package parsers;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;

public class MyWebClient {
	private static final String[] DISALLOWED_URLS = {
			"*push.atg.se/*"
	};

	private MyWebClient() {

	}

	private static final MyWebClient instance = new MyWebClient();

	public static MyWebClient getInstance() {
		return instance;
	}

	public WebClient getWebclient() {
		final WebClient webClient = new WebClient(BrowserVersion.CHROME);
		webClient.getOptions().setUseInsecureSSL(true);
		webClient.getOptions().setCssEnabled(true);
		webClient.getOptions().setJavaScriptEnabled(true);
		webClient.getOptions().setThrowExceptionOnScriptError(false);
		webClient.getOptions().setActiveXNative(true);

		//		webClient.getCache().setMaxSize(5);

		webClient.getOptions().setUseInsecureSSL(true);
		webClient.getOptions().setDoNotTrackEnabled(true);

		Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);

		webClient.waitForBackgroundJavaScript(3000);
		return webClient;
	}

	public WebClient getJsonWebClient() {
		final WebClient webClient = new WebClient(BrowserVersion.CHROME);
		webClient.getOptions().setUseInsecureSSL(true);
		webClient.getOptions().setCssEnabled(false);
		webClient.getOptions().setJavaScriptEnabled(false);
		webClient.getOptions().setThrowExceptionOnScriptError(false);
		webClient.getOptions().setActiveXNative(false);

		Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);

		return webClient;

	}

}
