X-Git-Url: https://git.sur5r.net/?p=minitube;a=blobdiff_plain;f=src%2Fmainwindow.cpp;fp=src%2Fmainwindow.cpp;h=610c0d16b680c69c78e49d0e0fd8977289293a77;hp=8b001ac0864d24e98fc67ddce7d113973c82eaa2;hb=9ff1806f2db97d617aa96185b7bf17f77bbacbcb;hpb=707b121e136bbb650f012ad9a55010acf6dea6fd diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8b001ac..610c0d1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(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);