mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-05 08:57:43 +00:00
fix(extension): support Google Drive video frames
This commit is contained in:
@@ -98,14 +98,15 @@ function loadTimelineFns(hostname, document = makeDocument(), pageApiTime = null
|
||||
].join('\n'))({ location: { hostname } }, document);
|
||||
}
|
||||
|
||||
function loadPlayerFixFns(hostname) {
|
||||
function loadPlayerFixFns(hostname, href = `https://${hostname}/`) {
|
||||
return Function('window', [
|
||||
extractFunction('hostMatchesUrl', source),
|
||||
extractFunction('matchesPlayerUrls', source),
|
||||
extractFunction('isGoogleDrivePlayerFrame', source),
|
||||
extractFunction('getPlayerActionFixes', source),
|
||||
extractFunction('getActivePlayerActionFix', source),
|
||||
'return { getPlayerActionFixes, getActivePlayerActionFix };'
|
||||
].join('\n'))({ location: { hostname } });
|
||||
'return { isGoogleDrivePlayerFrame, getPlayerActionFixes, getActivePlayerActionFix };'
|
||||
].join('\n'))({ location: { hostname, href } });
|
||||
}
|
||||
|
||||
const disneyFns = loadTimelineFns('www.disneyplus.com', makeDocument(), {
|
||||
@@ -147,6 +148,28 @@ const twitchFixFns = loadPlayerFixFns('player.twitch.tv');
|
||||
assert.equal(twitchFixFns.getActivePlayerActionFix().name, 'twitch-player-buttons');
|
||||
assert.deepEqual(twitchFixFns.getActivePlayerActionFix().urls, ['twitch.tv']);
|
||||
|
||||
const googleDriveFixFns = loadPlayerFixFns(
|
||||
'youtube.googleapis.com',
|
||||
'https://youtube.googleapis.com/embed/?origin=https%3A%2F%2Fdrive.google.com'
|
||||
);
|
||||
assert.equal(googleDriveFixFns.getActivePlayerActionFix().name, 'google-drive-player-buttons');
|
||||
assert.deepEqual(googleDriveFixFns.getActivePlayerActionFix().urls, ['youtube.googleapis.com']);
|
||||
const unrelatedGoogleEmbedFixFns = loadPlayerFixFns(
|
||||
'youtube.googleapis.com',
|
||||
'https://youtube.googleapis.com/embed/?origin=https%3A%2F%2Fexample.com'
|
||||
);
|
||||
assert.equal(unrelatedGoogleEmbedFixFns.getActivePlayerActionFix(), null);
|
||||
const googleDrivePlayerFns = Function('window', [
|
||||
extractFunction('isGoogleDrivePlayerFrame', source),
|
||||
'return { isGoogleDrivePlayerFrame };'
|
||||
].join('\n'))({
|
||||
location: {
|
||||
hostname: 'youtube.googleapis.com',
|
||||
href: 'https://youtube.googleapis.com/embed/?origin=https%3A%2F%2Fdrive.google.com'
|
||||
}
|
||||
});
|
||||
assert.equal(googleDrivePlayerFns.isGoogleDrivePlayerFrame(), true);
|
||||
|
||||
const genericFixFns = loadPlayerFixFns('example.com');
|
||||
assert.equal(genericFixFns.getActivePlayerActionFix(), null);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { cwd } from 'node:process';
|
||||
import {
|
||||
HOST_ACCESS_REQUIRED_STATUS,
|
||||
addTabHostAccessRequest,
|
||||
containsOriginPermission,
|
||||
describeTabUrl,
|
||||
inspectTabHostAccess,
|
||||
isHostAccessError,
|
||||
@@ -122,6 +123,17 @@ const callbackPermissionChrome = {
|
||||
};
|
||||
assert.equal(await requestOriginPermission(callbackPermissionChrome, 'https://video.example/*'), true);
|
||||
assert.equal(await requestOriginPermission({ permissions: {} }, 'https://video.example/*'), null);
|
||||
let containedOriginRequest = null;
|
||||
assert.equal(await containsOriginPermission({
|
||||
permissions: {
|
||||
contains: async request => {
|
||||
containedOriginRequest = request;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}, 'https://youtube.googleapis.com/*'), true);
|
||||
assert.deepEqual(containedOriginRequest, { origins: ['https://youtube.googleapis.com/*'] });
|
||||
assert.equal(await containsOriginPermission({ permissions: {} }, 'https://youtube.googleapis.com/*'), null);
|
||||
|
||||
const background = fs.readFileSync(path.join(cwd(), 'extension', 'background.js'), 'utf8');
|
||||
const popup = fs.readFileSync(path.join(cwd(), 'extension', 'popup.js'), 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user