mirror of
				https://github.com/SoPat712/videospeed.git
				synced 2025-10-29 18:30:35 -04:00 
			
		
		
		
	Fixed issue preventing last speed from being properly stored
This commit is contained in:
		
							
								
								
									
										17
									
								
								inject.js
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								inject.js
									
									
									
									
									
								
							| @@ -171,7 +171,7 @@ function defineVideoController() { | |||||||
|         // Ignore ratechange events on unitialized videos. |         // Ignore ratechange events on unitialized videos. | ||||||
|         // 0 == No information is available about the media resource. |         // 0 == No information is available about the media resource. | ||||||
|         if (event.target.readyState > 0) { |         if (event.target.readyState > 0) { | ||||||
|           rateChanged(this); |           rateChanged(this.div); | ||||||
|         } |         } | ||||||
|       }.bind(this)) |       }.bind(this)) | ||||||
|     ); |     ); | ||||||
| @@ -346,7 +346,6 @@ function initializeWhenReady(document) { | |||||||
|     "ratechange", |     "ratechange", | ||||||
|     function(event) { |     function(event) { | ||||||
|       if (coolDown) { |       if (coolDown) { | ||||||
|         refreshCoolDown(); |  | ||||||
|         console.log("Speed event propagation blocked"); |         console.log("Speed event propagation blocked"); | ||||||
|         event.stopImmediatePropagation(); |         event.stopImmediatePropagation(); | ||||||
|       } |       } | ||||||
| @@ -572,17 +571,19 @@ function initializeNow(document) { | |||||||
| function setSpeed(controller, video, speed) { | function setSpeed(controller, video, speed) { | ||||||
|   var speedvalue = speed.toFixed(2); |   var speedvalue = speed.toFixed(2); | ||||||
|   video.playbackRate = Number(speedvalue); |   video.playbackRate = Number(speedvalue); | ||||||
|   var speedIndicator = controller.shadowRoot.querySelector("span"); |  | ||||||
|   speedIndicator.textContent = speedvalue; |  | ||||||
|   refreshCoolDown(); |   refreshCoolDown(); | ||||||
|  |   rateChanged(controller); | ||||||
| } | } | ||||||
|  |  | ||||||
| function rateChanged(controller) { | function rateChanged(controller) { | ||||||
|   var speed = parseFloat(controller.video.playbackRate).toFixed(2); |   var speedIndicator = controller.shadowRoot.querySelector("span"); | ||||||
|   controller.speedIndicator.textContent = speed; |   var video = controller.parentElement.querySelector("video"); | ||||||
|   tc.settings.speeds[controller.video.currentSrc] = speed; |   var src = video.currentSrc; | ||||||
|  |   var speed = video.playbackRate.toFixed(2); | ||||||
|  |  | ||||||
|  |   speedIndicator.textContent = speed; | ||||||
|  |   tc.settings.speeds[src] = speed; | ||||||
|   tc.settings.lastSpeed = speed; |   tc.settings.lastSpeed = speed; | ||||||
|   controller.speed = speed; |  | ||||||
|   chrome.storage.sync.set({ lastSpeed: speed }, function() { |   chrome.storage.sync.set({ lastSpeed: speed }, function() { | ||||||
|     console.log("Speed setting saved: " + speed); |     console.log("Speed setting saved: " + speed); | ||||||
|   }); |   }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Chad Bailey
					Chad Bailey