Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added video controller #1287

Merged
merged 3 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Video Speed Controller/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// No background tasks in this extension, but you need a background script file.
8 changes: 8 additions & 0 deletions Video Speed Controller/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.speed) {
const videos = document.querySelectorAll('video');
videos.forEach(video => {
video.playbackRate = parseFloat(message.speed);
});
}
});
Binary file added Video Speed Controller/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Video Speed Controller/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"manifest_version": 3,
"name": "Video Speed Controller",
"version": "1.0",
"description": "Control video playback speed",
"permissions": ["activeTab"],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
}
},
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"host_permissions": [
"https://*/*",
"http://*/*"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
],
"background": {
"service_worker": "background.js"
},
"permissions": ["storage"]
}
17 changes: 17 additions & 0 deletions Video Speed Controller/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Speed Controller</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h2>Video Speed Controller</h2>
<div>
<input type="range" class="speed" min="0.5" max="2" step="0.1" value="1">
<span id="speedValue">1x</span>
</div>
<script src="popup.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions Video Speed Controller/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
document.addEventListener('DOMContentLoaded', function() {
const speedInput = document.querySelector('.speed');
const speedValue = document.getElementById('speedValue');

speedInput.addEventListener('input', function() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {speed: speedInput.value});
});
speedValue.textContent = speedInput.value + 'x';
});
});
12 changes: 12 additions & 0 deletions Video Speed Controller/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
body {
width: 200px;
padding: 20px;
}

input {
width: 100%;
}

h2 {
text-align: center;
}
Loading