mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-12-26 03:28:54 -05:00
updates for gpu usage
This commit is contained in:
16
build.py
16
build.py
@@ -63,14 +63,26 @@ def main():
|
||||
except Exception as e:
|
||||
print(f"⚠️ Failed to remove {f}: {e}")
|
||||
|
||||
# Read current version from manifest.json
|
||||
current_dir = os.getcwd()
|
||||
manifest_path = os.path.join(current_dir, TARGET_FILE)
|
||||
current_version = "unknown"
|
||||
|
||||
if os.path.exists(manifest_path):
|
||||
with open(manifest_path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
match = re.match(r'\s*"version":\s*"([^"]+)"', line)
|
||||
if match:
|
||||
current_version = match.group(1)
|
||||
break
|
||||
|
||||
print(f"📦 Current version: {current_version}")
|
||||
base_version = input("Enter the new base version (e.g., 2.0.1): ").strip()
|
||||
if not base_version:
|
||||
print("❌ No version entered. Exiting.")
|
||||
return
|
||||
|
||||
firefox_version = f"{base_version}.0"
|
||||
current_dir = os.getcwd()
|
||||
manifest_path = os.path.join(current_dir, TARGET_FILE)
|
||||
|
||||
# Step 1: Update manifest.json on disk to base_version
|
||||
if os.path.exists(manifest_path):
|
||||
|
||||
97
inject.js
97
inject.js
@@ -184,7 +184,7 @@ function defineVideoController() {
|
||||
target.vsc = this;
|
||||
this.video = target;
|
||||
this.parent = target.parentElement || parent;
|
||||
this.nudgeIntervalId = null;
|
||||
this.nudgeAnimationId = null;
|
||||
|
||||
log(`Creating video controller for ${target.tagName} with src: ${target.src || target.currentSrc || 'none'}`, 4);
|
||||
|
||||
@@ -367,64 +367,87 @@ function defineVideoController() {
|
||||
this.video.currentSrc &&
|
||||
this.video.currentSrc.includes("googlevideo.com")) ||
|
||||
location.hostname.includes("youtube.com");
|
||||
if (!isYouTube) return;
|
||||
if (
|
||||
!isYouTube ||
|
||||
!tc.settings.enableSubtitleNudge ||
|
||||
this.nudgeIntervalId !== null ||
|
||||
!this.video
|
||||
this.nudgeAnimationId !== null ||
|
||||
!this.video ||
|
||||
this.video.paused ||
|
||||
this.video.playbackRate === 1.0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (this.video.paused || this.video.playbackRate === 1.0) {
|
||||
this.stopSubtitleNudge();
|
||||
return;
|
||||
}
|
||||
// Additional check to not start if paused
|
||||
if (this.video.paused) {
|
||||
return;
|
||||
}
|
||||
log(`Nudge: Starting interval: ${tc.settings.subtitleNudgeInterval}ms.`, 5);
|
||||
this.nudgeIntervalId = setInterval(() => {
|
||||
if (
|
||||
!this.video ||
|
||||
this.video.paused ||
|
||||
this.video.ended ||
|
||||
this.video.playbackRate === 1.0 ||
|
||||
tc.isNudging
|
||||
) {
|
||||
this.stopSubtitleNudge();
|
||||
return;
|
||||
}
|
||||
// Double-check pause state before nudging
|
||||
if (this.video.paused) {
|
||||
|
||||
const performNudge = () => {
|
||||
// Check if we should stop
|
||||
if (!this.video || this.video.paused || this.video.playbackRate === 1.0) {
|
||||
this.stopSubtitleNudge();
|
||||
return;
|
||||
}
|
||||
|
||||
const currentRate = this.video.playbackRate;
|
||||
const nudgeAmount = tc.settings.subtitleNudgeAmount;
|
||||
tc.isNudging = true;
|
||||
|
||||
// Apply nudge
|
||||
this.video.playbackRate = currentRate + nudgeAmount;
|
||||
|
||||
// Revert on next frame
|
||||
requestAnimationFrame(() => {
|
||||
if (
|
||||
this.video &&
|
||||
Math.abs(this.video.playbackRate - (currentRate + nudgeAmount)) <
|
||||
nudgeAmount * 1.5
|
||||
) {
|
||||
if (this.video) {
|
||||
this.video.playbackRate = currentRate;
|
||||
}
|
||||
tc.isNudging = false;
|
||||
});
|
||||
}, tc.settings.subtitleNudgeInterval);
|
||||
|
||||
// Schedule next nudge using setTimeout instead of continuous RAF loop
|
||||
this.nudgeAnimationId = setTimeout(performNudge, tc.settings.subtitleNudgeInterval);
|
||||
};
|
||||
|
||||
// Start the first nudge
|
||||
this.nudgeAnimationId = setTimeout(performNudge, tc.settings.subtitleNudgeInterval);
|
||||
log(`Nudge: Starting with interval ${tc.settings.subtitleNudgeInterval}ms.`, 5);
|
||||
};
|
||||
|
||||
tc.videoController.prototype.stopSubtitleNudge = function () {
|
||||
if (this.nudgeIntervalId !== null) {
|
||||
if (this.nudgeAnimationId !== null) {
|
||||
clearTimeout(this.nudgeAnimationId);
|
||||
this.nudgeAnimationId = null;
|
||||
log(`Nudge: Stopping.`, 5);
|
||||
clearInterval(this.nudgeIntervalId);
|
||||
this.nudgeIntervalId = null;
|
||||
}
|
||||
};
|
||||
|
||||
tc.videoController.prototype.performImmediateNudge = function () {
|
||||
const isYouTube =
|
||||
(this.video &&
|
||||
this.video.currentSrc &&
|
||||
this.video.currentSrc.includes("googlevideo.com")) ||
|
||||
location.hostname.includes("youtube.com");
|
||||
|
||||
if (
|
||||
!isYouTube ||
|
||||
!tc.settings.enableSubtitleNudge ||
|
||||
!this.video ||
|
||||
this.video.paused ||
|
||||
this.video.playbackRate === 1.0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentRate = this.video.playbackRate;
|
||||
const nudgeAmount = tc.settings.subtitleNudgeAmount;
|
||||
|
||||
// Apply nudge
|
||||
this.video.playbackRate = currentRate + nudgeAmount;
|
||||
|
||||
// Revert on next frame
|
||||
requestAnimationFrame(() => {
|
||||
if (this.video) {
|
||||
this.video.playbackRate = currentRate;
|
||||
}
|
||||
});
|
||||
|
||||
log(`Immediate nudge performed at rate ${currentRate.toFixed(2)}`, 5);
|
||||
};
|
||||
|
||||
tc.videoController.prototype.initializeControls = function () {
|
||||
const doc = this.video.ownerDocument;
|
||||
const speed = this.video.playbackRate.toFixed(2);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Video Speed Controller",
|
||||
"short_name": "videospeed",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"manifest_version": 2,
|
||||
"description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts",
|
||||
"homepage_url": "https://github.com/SoPat712/videospeed",
|
||||
|
||||
Reference in New Issue
Block a user