updates for gpu usage

This commit is contained in:
Josh Patra
2025-11-19 14:11:55 -05:00
parent 1f8cb4411e
commit 5009e83f62
3 changed files with 75 additions and 40 deletions

View File

@@ -63,14 +63,26 @@ def main():
except Exception as e: except Exception as e:
print(f"⚠️ Failed to remove {f}: {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() base_version = input("Enter the new base version (e.g., 2.0.1): ").strip()
if not base_version: if not base_version:
print("❌ No version entered. Exiting.") print("❌ No version entered. Exiting.")
return return
firefox_version = f"{base_version}.0" 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 # Step 1: Update manifest.json on disk to base_version
if os.path.exists(manifest_path): if os.path.exists(manifest_path):

View File

@@ -184,7 +184,7 @@ function defineVideoController() {
target.vsc = this; target.vsc = this;
this.video = target; this.video = target;
this.parent = target.parentElement || parent; 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); 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 &&
this.video.currentSrc.includes("googlevideo.com")) || this.video.currentSrc.includes("googlevideo.com")) ||
location.hostname.includes("youtube.com"); location.hostname.includes("youtube.com");
if (!isYouTube) return;
if ( if (
!isYouTube ||
!tc.settings.enableSubtitleNudge || !tc.settings.enableSubtitleNudge ||
this.nudgeIntervalId !== null || this.nudgeAnimationId !== null ||
!this.video
) {
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 ||
this.video.paused || this.video.paused ||
this.video.ended || this.video.playbackRate === 1.0
this.video.playbackRate === 1.0 ||
tc.isNudging
) { ) {
return;
}
const performNudge = () => {
// Check if we should stop
if (!this.video || this.video.paused || this.video.playbackRate === 1.0) {
this.stopSubtitleNudge(); this.stopSubtitleNudge();
return; return;
} }
// Double-check pause state before nudging
if (this.video.paused) {
this.stopSubtitleNudge();
return;
}
const currentRate = this.video.playbackRate; const currentRate = this.video.playbackRate;
const nudgeAmount = tc.settings.subtitleNudgeAmount; const nudgeAmount = tc.settings.subtitleNudgeAmount;
tc.isNudging = true;
// Apply nudge
this.video.playbackRate = currentRate + nudgeAmount; this.video.playbackRate = currentRate + nudgeAmount;
// Revert on next frame
requestAnimationFrame(() => { requestAnimationFrame(() => {
if ( if (this.video) {
this.video &&
Math.abs(this.video.playbackRate - (currentRate + nudgeAmount)) <
nudgeAmount * 1.5
) {
this.video.playbackRate = currentRate; 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 () { tc.videoController.prototype.stopSubtitleNudge = function () {
if (this.nudgeIntervalId !== null) { if (this.nudgeAnimationId !== null) {
clearTimeout(this.nudgeAnimationId);
this.nudgeAnimationId = null;
log(`Nudge: Stopping.`, 5); 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 () { tc.videoController.prototype.initializeControls = function () {
const doc = this.video.ownerDocument; const doc = this.video.ownerDocument;
const speed = this.video.playbackRate.toFixed(2); const speed = this.video.playbackRate.toFixed(2);

View File

@@ -1,7 +1,7 @@
{ {
"name": "Video Speed Controller", "name": "Video Speed Controller",
"short_name": "videospeed", "short_name": "videospeed",
"version": "2.0.0", "version": "2.0.1",
"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",