mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-21 16:36:44 +00:00
32 lines
1000 B
JavaScript
32 lines
1000 B
JavaScript
(function(root) {
|
|
const PAGE_API_SEEK_FIXES = [
|
|
{
|
|
name: 'netflix-page-api-seek',
|
|
urls: ['netflix.com'],
|
|
provider: 'netflix'
|
|
}
|
|
];
|
|
|
|
function normalizeHost(input) {
|
|
try {
|
|
return new URL(input).hostname.toLowerCase();
|
|
} catch (_e) {
|
|
return String(input || '').toLowerCase();
|
|
}
|
|
}
|
|
|
|
function matchesDomain(host, domain) {
|
|
const normalizedDomain = normalizeHost(domain);
|
|
return normalizedDomain && (host === normalizedDomain || host.endsWith(`.${normalizedDomain}`));
|
|
}
|
|
|
|
root.KOALA_PAGE_API_SEEK_FIXES = PAGE_API_SEEK_FIXES;
|
|
root.KOALA_PAGE_API_SEEK_PROVIDERS = PAGE_API_SEEK_FIXES;
|
|
root.koalaFindPageApiSeekProvider = (input) => {
|
|
const host = normalizeHost(input);
|
|
return PAGE_API_SEEK_FIXES.find(entry =>
|
|
Array.isArray(entry.urls) && entry.urls.some(url => matchesDomain(host, url))
|
|
) || null;
|
|
};
|
|
})(globalThis);
|