File tree Expand file tree Collapse file tree 6 files changed +114
-0
lines changed
Sources/ContentScopeScripts/dist Expand file tree Collapse file tree 6 files changed +114
-0
lines changed Original file line number Diff line number Diff line change 51335133 // Mark that user opted into Kahf Player to prevent video from resuming
51345134 this.userOptedIntoKahfPlayer = true;
51355135
5136+ // Immediately pause the video to prevent it from playing
5137+ const video = /** @type {HTMLVideoElement} */(document.querySelector(this.settings.selectors.videoElement));
5138+ if (video?.isConnected) {
5139+ video.pause();
5140+
5141+ // Add a temporary pause mechanism to handle any race conditions
5142+ // This ensures the video stays paused even if other code tries to play it
5143+ const pauseInterval = setInterval(() => {
5144+ if (video?.isConnected && !video.paused) {
5145+ video.pause();
5146+ }
5147+ }, 50);
5148+
5149+ // Stop the pause interval after 2 seconds (enough time for navigation)
5150+ setTimeout(() => {
5151+ clearInterval(pauseInterval);
5152+ }, 2000);
5153+ }
5154+
51365155 /** @type {import("../duck-player.js").UserValues['privatePlayerMode']} */
51375156 let privatePlayerMode = { alwaysAsk: {} };
51385157 if (remember) {
Original file line number Diff line number Diff line change 1390713907 // Mark that user opted into Kahf Player to prevent video from resuming
1390813908 this.userOptedIntoKahfPlayer = true;
1390913909
13910+ // Immediately pause the video to prevent it from playing
13911+ const video = /** @type {HTMLVideoElement} */(document.querySelector(this.settings.selectors.videoElement));
13912+ if (video?.isConnected) {
13913+ video.pause();
13914+
13915+ // Add a temporary pause mechanism to handle any race conditions
13916+ // This ensures the video stays paused even if other code tries to play it
13917+ const pauseInterval = setInterval(() => {
13918+ if (video?.isConnected && !video.paused) {
13919+ video.pause();
13920+ }
13921+ }, 50);
13922+
13923+ // Stop the pause interval after 2 seconds (enough time for navigation)
13924+ setTimeout(() => {
13925+ clearInterval(pauseInterval);
13926+ }, 2000);
13927+ }
13928+
1391013929 /** @type {import("../duck-player.js").UserValues['privatePlayerMode']} */
1391113930 let privatePlayerMode = { alwaysAsk: {} };
1391213931 if (remember) {
Original file line number Diff line number Diff line change 1351013510 // Mark that user opted into Kahf Player to prevent video from resuming
1351113511 this.userOptedIntoKahfPlayer = true;
1351213512
13513+ // Immediately pause the video to prevent it from playing
13514+ const video = /** @type {HTMLVideoElement} */(document.querySelector(this.settings.selectors.videoElement));
13515+ if (video?.isConnected) {
13516+ video.pause();
13517+
13518+ // Add a temporary pause mechanism to handle any race conditions
13519+ // This ensures the video stays paused even if other code tries to play it
13520+ const pauseInterval = setInterval(() => {
13521+ if (video?.isConnected && !video.paused) {
13522+ video.pause();
13523+ }
13524+ }, 50);
13525+
13526+ // Stop the pause interval after 2 seconds (enough time for navigation)
13527+ setTimeout(() => {
13528+ clearInterval(pauseInterval);
13529+ }, 2000);
13530+ }
13531+
1351313532 /** @type {import("../duck-player.js").UserValues['privatePlayerMode']} */
1351413533 let privatePlayerMode = { alwaysAsk: {} };
1351513534 if (remember) {
Original file line number Diff line number Diff line change 1351013510 // Mark that user opted into Kahf Player to prevent video from resuming
1351113511 this.userOptedIntoKahfPlayer = true;
1351213512
13513+ // Immediately pause the video to prevent it from playing
13514+ const video = /** @type {HTMLVideoElement} */(document.querySelector(this.settings.selectors.videoElement));
13515+ if (video?.isConnected) {
13516+ video.pause();
13517+
13518+ // Add a temporary pause mechanism to handle any race conditions
13519+ // This ensures the video stays paused even if other code tries to play it
13520+ const pauseInterval = setInterval(() => {
13521+ if (video?.isConnected && !video.paused) {
13522+ video.pause();
13523+ }
13524+ }, 50);
13525+
13526+ // Stop the pause interval after 2 seconds (enough time for navigation)
13527+ setTimeout(() => {
13528+ clearInterval(pauseInterval);
13529+ }, 2000);
13530+ }
13531+
1351313532 /** @type {import("../duck-player.js").UserValues['privatePlayerMode']} */
1351413533 let privatePlayerMode = { alwaysAsk: {} };
1351513534 if (remember) {
Original file line number Diff line number Diff line change 1037410374 // Mark that user opted into Kahf Player to prevent video from resuming
1037510375 this.userOptedIntoKahfPlayer = true;
1037610376
10377+ // Immediately pause the video to prevent it from playing
10378+ const video = /** @type {HTMLVideoElement} */(document.querySelector(this.settings.selectors.videoElement));
10379+ if (video?.isConnected) {
10380+ video.pause();
10381+
10382+ // Add a temporary pause mechanism to handle any race conditions
10383+ // This ensures the video stays paused even if other code tries to play it
10384+ const pauseInterval = setInterval(() => {
10385+ if (video?.isConnected && !video.paused) {
10386+ video.pause();
10387+ }
10388+ }, 50);
10389+
10390+ // Stop the pause interval after 2 seconds (enough time for navigation)
10391+ setTimeout(() => {
10392+ clearInterval(pauseInterval);
10393+ }, 2000);
10394+ }
10395+
1037710396 /** @type {import("../duck-player.js").UserValues['privatePlayerMode']} */
1037810397 let privatePlayerMode = { alwaysAsk: {} };
1037910398 if (remember) {
Original file line number Diff line number Diff line change @@ -325,6 +325,25 @@ export class VideoOverlay {
325325 // Mark that user opted into Kahf Player to prevent video from resuming
326326 this . userOptedIntoKahfPlayer = true
327327
328+ // Immediately pause the video to prevent it from playing
329+ const video = /** @type {HTMLVideoElement } */ ( document . querySelector ( this . settings . selectors . videoElement ) )
330+ if ( video ?. isConnected ) {
331+ video . pause ( )
332+
333+ // Add a temporary pause mechanism to handle any race conditions
334+ // This ensures the video stays paused even if other code tries to play it
335+ const pauseInterval = setInterval ( ( ) => {
336+ if ( video ?. isConnected && ! video . paused ) {
337+ video . pause ( )
338+ }
339+ } , 50 )
340+
341+ // Stop the pause interval after 2 seconds (enough time for navigation)
342+ setTimeout ( ( ) => {
343+ clearInterval ( pauseInterval )
344+ } , 2000 )
345+ }
346+
328347 /** @type {import("../duck-player.js").UserValues['privatePlayerMode'] } */
329348 let privatePlayerMode = { alwaysAsk : { } }
330349 if ( remember ) {
You can’t perform that action at this time.
0 commit comments