diff --git a/app/gamePreload.js b/app/gamePreload.js index 6446ee9..cc20766 100644 --- a/app/gamePreload.js +++ b/app/gamePreload.js @@ -6,6 +6,7 @@ const sendWhitelist = new Set() .add("initialized") .add("fps") .add("openPage") + .add("ownVideo") .add("presence") .add("printImage") .add("reloadGame") @@ -15,6 +16,7 @@ const sendWhitelist = new Set() const receiveWhitelist = new Set() .add("flashVarsReady") .add("hud") + .add("ownVideoReady") .add("removed"); contextBridge.exposeInMainWorld( diff --git a/app/index.html b/app/index.html index 878befe..61aa517 100644 --- a/app/index.html +++ b/app/index.html @@ -1166,6 +1166,12 @@ // main.js opens http and https addresses only window.client.openPage(String(event.args[0])); } + else if (event.channel === "ownVideo") { + // the player's own theatre video (the game page's link box): main.js + // lets that one address load, then the page plays it. + const link = String(event.args[0] || ""); + window.client.ownVideo(link).then(() => webview.send("ownVideoReady", link)); + } else if (event.channel === "presence") { // where the player is now (the game's AJClient.presenceRoom) showPresence(String(event.args[0] || "")); diff --git a/app/main.js b/app/main.js index 5c89737..03bf8cb 100644 --- a/app/main.js +++ b/app/main.js @@ -220,6 +220,25 @@ ipcMain.handle("useServer", (event, serverUrl, gamePort, gameHost) => { // fetch from elsewhere (a picture named in a chat line once did) would hand // a stranger the player's address, or the plugin a stranger's file. const LOCAL_SCHEMES = ["file:", "devtools:", "chrome-devtools:", "chrome:", "data:", "blob:", "about:"]; + +// the theatre's video (the server's game page: the room's, played by staff, +// and the player's own from its link box): the YouTube and Vimeo players +// and what they load, measured in this Electron. a host here counts with +// every host under it. +const VIDEO_PLAYER_HOSTS = [ + "youtube-nocookie.com", "youtube.com", "ytimg.com", "ggpht.com", "googlevideo.com", + "jnn-pa.googleapis.com", "gstatic.com", "www.google.com", + "vimeo.com", "vimeocdn.com", +]; +const videoPlayerHost = host => VIDEO_PLAYER_HOSTS.some(known => host === known || host.endsWith(`.${known}`)); +// the player's own sound or video file (the game page's link box): the one +// address they typed, as the game page says it (ownVideo below), and where +// it redirects. a