Skip to content

Commit

Permalink
Merge pull request #71 from felipealfonsog/development
Browse files Browse the repository at this point in the history
Updates - fixes useragent c++ version
  • Loading branch information
felipealfonsog authored Mar 16, 2024
2 parents ea78966 + 5ec0aaa commit 0285781
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/cpp/novanav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,33 @@ void show_url_input_dialog() {


void create_new_tab(const QString &url) {
QWebEngineView *browser = new QWebEngineView();



// Habilitar JavaScript
browser->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
// Creamos un nuevo perfil de navegación
QWebEngineProfile *profile = new QWebEngineProfile("CustomProfile");

if (!url.startsWith("http"))
browser->setUrl(QUrl("http://" + url));
else
browser->setUrl(QUrl(url));
// Modificamos el User-Agent en ciertos sitios web
profile->setHttpUserAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36");

// Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
// browser->page()->profile()->setHttpUserAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36");
// browser->page()->profile()->setHttpUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36");
browser->page()->profile()->setHttpUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36");
// browser->page()->profile()->setHttpUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36");


// sqDebug() << "User-Agent:" << browser->page()->profile()->httpUserAgent();



// Creamos el QWebEngineView y establecemos la URL
QWebEngineView *browser = new QWebEngineView();
if (!url.startsWith("http"))
browser->setUrl(QUrl("http://" + url));
else
browser->setUrl(QUrl(url));

// Habilitamos JavaScript
browser->page()->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);

// Conectamos señales de cambio de título y URL
connect(browser, &QWebEngineView::titleChanged, this, [=](const QString &title) {
set_tab_title(browser, title.left(20));
});
Expand All @@ -153,6 +159,7 @@ void create_new_tab(const QString &url) {
}
});

// Agregamos el QWebEngineView a la pestaña
tab_widget->addTab(browser, "");
browser->setZoomFactor(0.67); // Zoom por defecto
}
Expand Down

0 comments on commit 0285781

Please sign in to comment.