fix: fix trustedHTML issue

- (Maybe) fix #2339, caused by YouTube's A/B testing
This commit is contained in:
JellyBrick
2024-09-17 20:05:22 +09:00
parent dbb9e95b32
commit d5a5ed35b6
4 changed files with 19 additions and 0 deletions

View File

@ -214,6 +214,7 @@
"@types/howler": "2.2.11",
"@types/html-to-text": "9.0.4",
"@types/semver": "7.5.8",
"@types/trusted-types": "2.0.7",
"@typescript-eslint/eslint-plugin": "8.6.0",
"@typescript-eslint/parser": "8.6.0",
"bufferutil": "4.0.8",

8
pnpm-lock.yaml generated
View File

@ -190,6 +190,9 @@ importers:
'@types/semver':
specifier: 7.5.8
version: 7.5.8
'@types/trusted-types':
specifier: 2.0.7
version: 2.0.7
'@typescript-eslint/eslint-plugin':
specifier: 8.6.0
version: 8.6.0(@typescript-eslint/parser@8.6.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4)
@ -1137,6 +1140,9 @@ packages:
'@types/semver@7.5.8':
resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==}
'@types/trusted-types@2.0.7':
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
'@types/verror@1.10.10':
resolution: {integrity: sha512-l4MM0Jppn18hb9xmM6wwD1uTdShpf9Pn80aXTStnK1C94gtPvJcV2FrDmbOQUAQfJ1cKZHktkQUDwEqaAKXMMg==}
@ -4895,6 +4901,8 @@ snapshots:
'@types/semver@7.5.8': {}
'@types/trusted-types@2.0.7': {}
'@types/verror@1.10.10':
optional: true

View File

@ -23,6 +23,14 @@ let isPluginLoaded = false;
let isApiLoaded = false;
let firstDataLoaded = false;
if (window.trustedTypes && window.trustedTypes.createPolicy && !window.trustedTypes.defaultPolicy) {
window.trustedTypes.createPolicy('default', {
createHTML: (input) => input,
createScriptURL: (input) => input,
createScript: (input) => input,
});
}
async function listenForApiLoad() {
if (!isApiLoaded) {
api = document.querySelector('#movie_player');

2
src/reset.d.ts vendored
View File

@ -6,6 +6,7 @@ import type is from 'electron-is';
import type config from './config';
import type { VideoDataChanged } from '@/types/video-data-changed';
import type { t } from '@/i18n';
import type { trustedTypes } from 'trusted-types';
declare global {
interface Compressor {
@ -19,6 +20,7 @@ declare global {
}
interface Window {
trustedTypes?: typeof trustedTypes;
ipcRenderer: typeof electronIpcRenderer;
mainConfig: typeof config;
electronIs: typeof is;