mirror of
https://github.com/Zaarrg/stremio-community-v5.git
synced 2026-01-11 20:10:31 +00:00
- Added extension domain whitelist gotten from extensions.json on github for allowed domains to navigate for browser extension usage. App allow these domain to be navigated to other are open externally. - Added script Queue to run scripts on navigation complete - Added "Home" navigate event arg, to navigate back to home page - Added Back to Stremio button when not on Stremio page - Partial permid support with custom patch. Still some features not working.
39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
#include "extensions.h"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include "../core/globals.h"
|
|
|
|
void HandlePremidLogin(const std::wstring& finalUri) {
|
|
if (finalUri.rfind(L"https://login.premid.app", 0) == 0 && finalUri.rfind(L"https://discord.com", 0) != 0) {
|
|
std::wstring extensionId;
|
|
auto it = std::find_if(g_extensionMap.begin(), g_extensionMap.end(),
|
|
[](const std::pair<std::wstring, std::wstring>& p) -> bool {
|
|
return p.first.find(L"premid") != std::wstring::npos;
|
|
});
|
|
if (it != g_extensionMap.end()) {
|
|
extensionId = it->second;
|
|
} else {
|
|
std::wcout << L"[EXTENSIONS]: Extension id not found\n";
|
|
g_webview->Navigate(g_webuiUrl.c_str());
|
|
return;
|
|
}
|
|
|
|
std::wstring codeParam;
|
|
size_t codePos = finalUri.find(L"code=");
|
|
if (codePos != std::wstring::npos) {
|
|
codePos += 5; // Move past "code="
|
|
size_t ampPos = finalUri.find(L'&', codePos);
|
|
if (ampPos == std::wstring::npos) {
|
|
codeParam = finalUri.substr(codePos);
|
|
} else {
|
|
codeParam = finalUri.substr(codePos, ampPos - codePos);
|
|
}
|
|
}
|
|
std::wstring script = L"globalThis.getAuthorizationCode(\"" + codeParam + L"\");";
|
|
g_scriptQueue.push_back(script);
|
|
|
|
std::wstring uri = L"chrome-extension://" + extensionId + L"/popup.html";
|
|
g_webview->Navigate(uri.c_str());
|
|
}
|
|
}
|