From 54c88dcb2fd928ca640f361a08e5b69253405e17 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 28 Aug 2021 02:24:23 +0200 Subject: [PATCH 01/13] we no longer have gitlab --- .gitlab-ci.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 070b6cb..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,23 +0,0 @@ -image: node:current - -cache: - paths: - - node_modules/ - - .yarn - -stages: - - prep - - build - - pack - -install deps: - stage: prep - script: yarn install - -build: - stage: build - script: npm run build - -create zip: - stage: pack - script: npm run build-zip \ No newline at end of file From 820af9b133aa7bff1bab990aee3d460c9ff00e85 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Mon, 13 Sep 2021 22:47:27 +0200 Subject: [PATCH 02/13] Patch for netflix --- src/ext/conf/ExtConfPatches.js | 7 +++++++ src/ext/conf/ExtensionConf.ts | 10 +++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ext/conf/ExtConfPatches.js b/src/ext/conf/ExtConfPatches.js index b00357c..fa2f87f 100644 --- a/src/ext/conf/ExtConfPatches.js +++ b/src/ext/conf/ExtConfPatches.js @@ -234,6 +234,13 @@ const ExtensionConfPatch = [ playerNodeCss: "", } } + }, { + forVersion: '5.0.8', + updateFn: (userOptions, defaultOptions) => { + userOptions.sites['www.netflix.com'].DOM.player = { + manual: false + } + } } ]; diff --git a/src/ext/conf/ExtensionConf.ts b/src/ext/conf/ExtensionConf.ts index 6bd56d1..e5eca49 100644 --- a/src/ext/conf/ExtensionConf.ts +++ b/src/ext/conf/ExtensionConf.ts @@ -1048,13 +1048,9 @@ const ExtensionConf: SettingsInterface = { videoAlignment: VideoAlignmentType.Default, keyboardShortcutsEnabled: ExtensionMode.Default, arPersistence: true, // persist aspect ratio between different videos - "DOM": { - "player": { - "manual": true, - "querySelectors": ".VideoContainer", - "additionalCss": "", - "useRelativeAncestor": false, - "playerNodeCss": "" + DOM: { + player: { + manual: false, // as of 2021-09, netflix no longer requires manual player class. This may change in the future tho. } } }, From b1ec4f7387ddf630456d3d9a80e6f767e7f60dc0 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 14 Sep 2021 19:12:54 +0200 Subject: [PATCH 03/13] Make framecheck ever so slightly async --- src/ext/lib/ar-detect/ArDetector.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ext/lib/ar-detect/ArDetector.ts b/src/ext/lib/ar-detect/ArDetector.ts index b87aa44..a6282c8 100644 --- a/src/ext/lib/ar-detect/ArDetector.ts +++ b/src/ext/lib/ar-detect/ArDetector.ts @@ -660,7 +660,7 @@ class ArDetector { id = undefined; } - frameCheck(){ + async frameCheck(){ if(! this.video){ this.logger.log('error', 'debug', `%c[ArDetect::frameCheck] <@${this.arid}> Video went missing. Destroying current instance of videoData.`); this.conf.destroy(); @@ -680,7 +680,15 @@ class ArDetector { // try { startTime = performance.now(); - this.blackframeContext.drawImage(this.video, 0, 0, this.blackframeCanvas.width, this.blackframeCanvas.height); + + // do it in ghetto async. This way, other javascript function should be able to + // get a chance to do something _before_ we process our data + await new Promise( + resolve => { + this.blackframeContext.drawImage(this.video, 0, 0, this.blackframeCanvas.width, this.blackframeCanvas.height); + resolve(); + } + ); partialDrawImageTime += performance.now() - startTime; this.fallbackMode = false; @@ -726,7 +734,9 @@ class ArDetector { return; // it's prolly just a fluke, so we do nothing special here } // draw blackframe sample from our main sample: - this.blackframeContext.drawImage(this.canvas, this.blackframeCanvas.width, this.blackframeCanvas.height); + await new Promise(resolve => { + this.blackframeContext.drawImage(this.canvas, this.blackframeCanvas.width, this.blackframeCanvas.height); + }); partialDrawImageTime += performance.now() - startTime; this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] canvas.drawImage seems to have worked`, "color:#000; backgroud:#2f5;"); @@ -743,7 +753,9 @@ class ArDetector { // if we are in normal mode though, the frame has yet to be drawn if (!this.fallbackMode) { startTime = performance.now(); - this.context.drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height); + await new Promise(resolve => { + this.context.drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height); + }) partialDrawImageTime += performance.now() - startTime; } From 415ebf6821a5f932dbce15d2d38dcd40f1427d9d Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 14 Sep 2021 23:21:53 +0200 Subject: [PATCH 04/13] Simplify video rescans --- .vscode/settings.json | 6 +- src/ext/lib/ar-detect/ArDetector.ts | 2 - src/ext/lib/video-data/PageInfo.ts | 200 ++++++++++++++-------------- 3 files changed, 103 insertions(+), 105 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2775218..2092956 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,5 @@ { "cSpell.words": [ - "PILLARBOX", - "PILLARBOXED", "aard", "ardetector", "autodetect", @@ -16,6 +14,7 @@ "csui", "decycle", "disneyplus", + "endregion", "equalish", "fith", "fitw", @@ -24,6 +23,7 @@ "gmail", "guardline", "han", + "haram", "iframe", "imgur", "insta", @@ -34,6 +34,8 @@ "nogrow", "noshrink", "outro", + "PILLARBOX", + "PILLARBOXED", "polyfill", "recursing", "reddit", diff --git a/src/ext/lib/ar-detect/ArDetector.ts b/src/ext/lib/ar-detect/ArDetector.ts index a6282c8..ecc3187 100644 --- a/src/ext/lib/ar-detect/ArDetector.ts +++ b/src/ext/lib/ar-detect/ArDetector.ts @@ -833,8 +833,6 @@ class ArDetector { try{ if(guardLineOut.blackbarFail || guardLineOut.imageFail){ if(this.edgeDetector.findBars(imageData, null, EdgeDetectPrimaryDirection.Horizontal).status === 'ar_known'){ - - if(guardLineOut.blackbarFail){ this.logger.log('info', 'arDetect', `[ArDetect::frameCheck] Detected blackbar violation and pillarbox. Resetting to default aspect ratio.`); this.conf.resizer.setAr({type: AspectRatioType.Automatic, ratio: this.defaultAr}); diff --git a/src/ext/lib/video-data/PageInfo.ts b/src/ext/lib/video-data/PageInfo.ts index 76bd02a..52017cc 100644 --- a/src/ext/lib/video-data/PageInfo.ts +++ b/src/ext/lib/video-data/PageInfo.ts @@ -29,7 +29,7 @@ class PageInfo { logger: Logger; settings: Settings; comms: CommsClient; - videos: VideoData[] = []; + videos: {videoData: VideoData, element: HTMLVideoElement}[] = []; //#endregion //#region misc stuff @@ -113,8 +113,8 @@ class PageInfo { } for (let video of this.videos) { try { - (this.comms.unregisterVideo as any)(video.vdid) - video.destroy(); + (this.comms.unregisterVideo as any)(video.videoData.vdid) + video.videoData.destroy(); } catch (e) { this.logger.log('error', ['debug', 'init'], '[PageInfo::destroy] unable to destroy video! Error:', e); } @@ -135,8 +135,10 @@ class PageInfo { reset() { for(let video of this.videos) { - video.destroy(); + video.videoData.destroy(); + video.videoData = null; } + this.videos = []; this.rescan(RescanReason.MANUAL); } @@ -159,7 +161,7 @@ class PageInfo { getVideos(host) { if (this.settings.active.sites[host]?.DOM?.video?.manual && this.settings.active.sites[host]?.DOM?.video?.querySelectors){ - const videos = document.querySelectorAll(this.settings.active.sites[host].DOM.video.querySelectors); + const videos = document.querySelectorAll(this.settings.active.sites[host].DOM.video.querySelectors) as NodeListOf; if (videos.length) { return videos; @@ -172,9 +174,25 @@ class PageInfo { return this.readOnly ? this.hasVideos : this.videos.length; } - rescan(rescanReason){ - const oldVideoCount = this.videos.length; + /** + * Re-scans the page for videos. Removes any videos that no longer exist from our list + * of videos. Destroys all videoData objects for all the videos that don't have their + * own