mirror of
				https://github.com/SoPat712/videospeed.git
				synced 2025-10-31 02:43:59 -04:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			v1.2.1
			...
			3dfee251ec
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 3dfee251ec | 
							
								
								
									
										32
									
								
								inject.js
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								inject.js
									
									
									
									
									
								
							| @@ -174,40 +174,43 @@ function defineVideoController() { | |||||||
|     target.playbackRate = storedSpeed; |     target.playbackRate = storedSpeed; | ||||||
|     this.div = this.initializeControls(); |     this.div = this.initializeControls(); | ||||||
|  |  | ||||||
|     // FIXED: Make the controller visible for 5 seconds on startup |     // Make the controller visible for 5 seconds on startup | ||||||
|     runAction("blink", 5000, null, this.video); |     runAction("blink", 5000, null, this.video); | ||||||
|  |  | ||||||
|     // FIXED: Rewritten mediaEventAction to prevent speed reset on pause. |     // Rewritten mediaEventAction to prevent speed reset on pause. | ||||||
|     var mediaEventAction = function (event) { |     var mediaEventAction = function (event) { | ||||||
|       // Subtitle Nudge logic is based on play/pause state. |       // Handle subtitle nudging based on the event type first. | ||||||
|       if (event.type === "play") { |       if (event.type === "play") { | ||||||
|         this.startSubtitleNudge(); |         this.startSubtitleNudge(); | ||||||
|       } else if (event.type === "pause" || event.type === "ended") { |       } else if (event.type === "pause" || event.type === "ended") { | ||||||
|         this.stopSubtitleNudge(); |         this.stopSubtitleNudge(); | ||||||
|         // On pause or end, DO NOT proceed to change speed. |         // *** THE KEY FIX *** | ||||||
|         // This is the key fix for the pause-resets-speed bug. |         // On pause or end, we do NOT want to change the speed. | ||||||
|  |         // We only stop the nudger and exit the function immediately. | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       // Speed restoration logic (for "play" and non-user "seeked" events) |       // The rest of this logic will now ONLY run for "play" and "seeked" events. | ||||||
|  |  | ||||||
|  |       // If it's a seek initiated by our rewind/advance keys, do nothing. | ||||||
|       if (event.type === "seeked" && isUserSeek) { |       if (event.type === "seeked" && isUserSeek) { | ||||||
|         isUserSeek = false; // Reset flag |         isUserSeek = false; // Reset the flag for the next seek. | ||||||
|         return; // Don't change speed on user-initiated seeks. |         return; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       // Determine the speed that *should* be set, in case the site changed it. |       // Determine the speed that *should* be applied, in case the site changed it. | ||||||
|       let targetSpeed; |       let targetSpeed; | ||||||
|       if (tc.settings.forceLastSavedSpeed) { |       if (tc.settings.forceLastSavedSpeed) { | ||||||
|         targetSpeed = tc.settings.lastSpeed; |         targetSpeed = tc.settings.lastSpeed; | ||||||
|       } else if (tc.settings.rememberSpeed) { |       } else if (tc.settings.rememberSpeed) { | ||||||
|         targetSpeed = tc.settings.lastSpeed; |         targetSpeed = tc.settings.lastSpeed; | ||||||
|       } else { |       } else { | ||||||
|         // Fallback to per-video speed or 1.0 |         // Fallback to the speed saved for this specific video, or 1.0 | ||||||
|         targetSpeed = tc.settings.speeds[event.target.currentSrc] || 1.0; |         targetSpeed = tc.settings.speeds[event.target.currentSrc] || 1.0; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       // Only set the speed if the site has actually changed it. |       // Only re-apply the speed if the website has actually changed it. | ||||||
|       // This avoids unnecessary "ratechange" events. |       // This prevents redundant "ratechange" events. | ||||||
|       if (Math.abs(event.target.playbackRate - targetSpeed) > 0.01) { |       if (Math.abs(event.target.playbackRate - targetSpeed) > 0.01) { | ||||||
|         setSpeed(event.target, targetSpeed); |         setSpeed(event.target, targetSpeed); | ||||||
|       } |       } | ||||||
| @@ -390,7 +393,7 @@ function defineVideoController() { | |||||||
|         const r = parentEl.getRootNode(); |         const r = parentEl.getRootNode(); | ||||||
|         const s = r && r.querySelector ? r.querySelector(".scrim") : null; |         const s = r && r.querySelector ? r.querySelector(".scrim") : null; | ||||||
|         if (s) s.prepend(fragment); |         if (s) s.prepend(fragment); | ||||||
|         else parentEl.insertBefore(fragment, pEl.firstChild); |         else parentEl.insertBefore(fragment, parentEl.firstChild); | ||||||
|         break; |         break; | ||||||
|       default: |       default: | ||||||
|         parentEl.insertBefore(fragment, parentEl.firstChild); |         parentEl.insertBefore(fragment, parentEl.firstChild); | ||||||
| @@ -831,7 +834,6 @@ function pause(v) { | |||||||
|   else v.pause(); |   else v.pause(); | ||||||
| } | } | ||||||
|  |  | ||||||
| // FIXED: Using the improved resetSpeed function for toggling |  | ||||||
| function resetSpeed(v, target, isFastKey = false) { | function resetSpeed(v, target, isFastKey = false) { | ||||||
|   const videoId = v.currentSrc || v.src || "default"; |   const videoId = v.currentSrc || v.src || "default"; | ||||||
|   const currentSpeed = v.playbackRate; |   const currentSpeed = v.playbackRate; | ||||||
| @@ -879,7 +881,6 @@ function jumpToMark(v) { | |||||||
|   if (v.vsc && typeof v.vsc.mark === "number") v.currentTime = v.vsc.mark; |   if (v.vsc && typeof v.vsc.mark === "number") v.currentTime = v.vsc.mark; | ||||||
| } | } | ||||||
| function handleDrag(video, e) { | function handleDrag(video, e) { | ||||||
|   /* ... Same original logic ... */ |  | ||||||
|   const c = video.vsc.div; |   const c = video.vsc.div; | ||||||
|   const sC = c.shadowRoot.querySelector("#controller"); |   const sC = c.shadowRoot.querySelector("#controller"); | ||||||
|   var pE = c.parentElement; |   var pE = c.parentElement; | ||||||
| @@ -911,7 +912,6 @@ function handleDrag(video, e) { | |||||||
| } | } | ||||||
| var timer = null; | var timer = null; | ||||||
| function showController(controller) { | function showController(controller) { | ||||||
|   /* ... Same original logic ... */ |  | ||||||
|   if (!controller || typeof controller.classList === "undefined") return; |   if (!controller || typeof controller.classList === "undefined") return; | ||||||
|   controller.classList.add("vsc-show"); |   controller.classList.add("vsc-show"); | ||||||
|   if (timer) clearTimeout(timer); |   if (timer) clearTimeout(timer); | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| { | { | ||||||
|   "name": "Video Speed Controller", |   "name": "Video Speed Controller", | ||||||
|   "short_name": "videospeed", |   "short_name": "videospeed", | ||||||
|   "version": "1.2.1", |   "version": "1.2.1.0", | ||||||
|   "manifest_version": 2, |   "manifest_version": 2, | ||||||
|   "description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts", |   "description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts", | ||||||
|   "homepage_url": "https://github.com/SoPat712/videospeed", |   "homepage_url": "https://github.com/SoPat712/videospeed", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user