JavaFX WebView over Tor

46 Views Asked by At

I have a project that needs to access websites on Tor and view them on webview. (not android) Even though I tried every solution on the internet, I could not reach a solution. I also tried the libraries, but they do not give me the results I want. Can you help me on this issue?

package com.example.demo1;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;


public class HelloController {

    public Button backBtn;
    public Button ForwardBtn;
    @FXML
    private TextField urlTxt;
    @FXML
    private WebView webView;

    private WebEngine webEngine;

    public void initialize() {
        webEngine = webView.getEngine();
        webEngine.locationProperty().addListener((observable, oldValue, newValue) -> urlTxt.setText(newValue));
    }


    public void onGoBtnAction() {
        webEngine.load(urlTxt.getText());
    }

    public void onUrlTxtKeyPressed(KeyEvent keyEvent) {
        if (keyEvent.getCode() == KeyCode.ENTER) onGoBtnAction();
    }

    public void onBackBtnAction() {
        webEngine.executeScript("history.back()");
    }

    public void onForwardBtnAction() {
        webEngine.executeScript("history.forward()");
    }
}

Only thing I know is I don't want to save page with HttpConnection to loadContect, beacuse if I do that resources doesn't load correctly, so CSS' are disappearing and makes websites unreadable.

I tried setting SOCKS and HTTP proxy via setProperty. and various libraries.

0

There are 0 best solutions below