mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-22 02:18:45 -04:00
Moved logic in rate change event listener into its own function to be triggered by setSpeed()
This commit is contained in:
24
inject.js
24
inject.js
@@ -171,16 +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) {
|
||||||
var speed = this.getSpeed();
|
rateChanged(this);
|
||||||
this.speedIndicator.textContent = speed;
|
|
||||||
tc.settings.speeds[this.video.currentSrc] = speed;
|
|
||||||
tc.settings.lastSpeed = speed;
|
|
||||||
this.speed = speed;
|
|
||||||
chrome.storage.sync.set({ lastSpeed: speed }, function() {
|
|
||||||
console.log("Speed setting saved: " + speed);
|
|
||||||
});
|
|
||||||
// show the controller for 1000ms if it's hidden.
|
|
||||||
runAction("blink", document, null, null);
|
|
||||||
}
|
}
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
);
|
);
|
||||||
@@ -586,6 +577,19 @@ function setSpeed(controller, video, speed) {
|
|||||||
refreshCoolDown();
|
refreshCoolDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rateChanged(controller) {
|
||||||
|
var speed = parseFloat(controller.video.playbackRate).toFixed(2);
|
||||||
|
controller.speedIndicator.textContent = speed;
|
||||||
|
tc.settings.speeds[controller.video.currentSrc] = speed;
|
||||||
|
tc.settings.lastSpeed = speed;
|
||||||
|
controller.speed = speed;
|
||||||
|
chrome.storage.sync.set({ lastSpeed: speed }, function() {
|
||||||
|
console.log("Speed setting saved: " + speed);
|
||||||
|
});
|
||||||
|
// show the controller for 1000ms if it's hidden.
|
||||||
|
runAction("blink", document, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
function runAction(action, document, value, e) {
|
function runAction(action, document, value, e) {
|
||||||
if (tc.settings.audioBoolean) {
|
if (tc.settings.audioBoolean) {
|
||||||
var mediaTags = getShadow(document.body).filter(x => {
|
var mediaTags = getShadow(document.body).filter(x => {
|
||||||
|
Reference in New Issue
Block a user