]> git.sur5r.net Git - minitube/blobdiff - src/mainwindow.cpp
New upstream version 3.9.1
[minitube] / src / mainwindow.cpp
index 8b001ac0864d24e98fc67ddce7d113973c82eaa2..610c0d16b680c69c78e49d0e0fd8977289293a77 100644 (file)
@@ -171,13 +171,16 @@ MainWindow::MainWindow()
     } else if (VideoAPI::impl() == VideoAPI::YT3) {
         YT3::instance().initApiKeys();
     } else if (VideoAPI::impl() == VideoAPI::JS) {
-        JS::instance().getNamFactory().setRequestHeaders(
-                {{"User-Agent", HttpUtils::stealthUserAgent()}});
         JS::instance().initialize(QUrl(QLatin1String(Constants::WEBSITE) + "-ws/bundle2.js"));
-        /// JS::instance().initialize(QUrl("http://localhost:8000/bundle-test.js"));
+        // JS::instance().initialize(QUrl("http://localhost:8000/bundle-test.js"));
         Invidious::instance().initServers();
     }
 
+    connect(JsFunctions::instance(), &JsFunctions::ready, this, [] {
+        auto ua = JsFunctions::instance()->string("userAgent()").toUtf8();
+        JS::instance().getNamFactory().setRequestHeaders({{"User-Agent", ua}});
+    });
+
     QTimer::singleShot(100, this, &MainWindow::lazyInit);
 }
 
@@ -226,8 +229,6 @@ void MainWindow::lazyInit() {
     fullscreenTimer->setSingleShot(true);
     connect(fullscreenTimer, SIGNAL(timeout()), SLOT(hideFullscreenUI()));
 
-    JsFunctions::instance();
-
     // Hack to give focus to searchlineedit
     View *view = qobject_cast<View *>(views->currentWidget());
     if (view == homeView) {
@@ -648,7 +649,7 @@ void MainWindow::createActions() {
     action->setEnabled(false);
     actionMap.insert("refineSearch", action);
 
-    action = new QAction(YTRegions::worldwideRegion().name, this);
+    action = new QAction(YTRegions::defaultRegion().name, this);
     actionMap.insert("worldwideRegion", action);
 
     action = new QAction(YTRegions::localRegion().name, this);