mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-21 09:58:45 -04:00
Merge upstream
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ local
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea/
|
||||
node_modules
|
||||
|
15
.pre-commit-config.yaml
Normal file
15
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
|
||||
- repo: https://github.com/prettier/prettier
|
||||
rev: 1.19.1 # Use the sha or tag you want to point at
|
||||
hooks:
|
||||
- id: prettier
|
8
.prettierrc
Normal file
8
.prettierrc
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"trailingComma": "none",
|
||||
"tabWidth": 2,
|
||||
"printWidth": 80,
|
||||
"semi": true,
|
||||
"endOfLine": "auto",
|
||||
"proseWrap": "always"
|
||||
}
|
65
README.md
65
README.md
@@ -2,38 +2,73 @@
|
||||
|
||||
**TL;DR: faster playback translates to better engagement and retention.**
|
||||
|
||||
Average adult reads prose text at [250 to 300 words per minute](http://www.paperbecause.com/PIOP/files/f7/f7bb6bc5-2c4a-466f-9ae7-b483a2c0dca4.pdf) (wpm). By contrast, the average rate of speech for English speakers is ~150 wpm, with slide presentations often closer to 100 wpm. As a result, when given the choice, many viewers [speed up video playback to ~1.3\~1.5 its recorded rate](http://research.microsoft.com/en-us/um/redmond/groups/coet/compression/chi99/paper.pdf) to compensate for the difference.
|
||||
|
||||
Many viewers report that [accelerated viewing keeps their attention longer](http://www.enounce.com/docs/BYUPaper020319.pdf): faster delivery keeps the viewer more engaged with the content. In fact, with a little training many end up watching videos at 2x+ the recorded speed. Some studies report that after being exposed to accelerated playback, [listeners become uncomfortable](http://alumni.media.mit.edu/~barons/html/avios92.html#beasleyalteredspeech) if they are forced to return to normal rate of presentation.
|
||||
Average adult reads prose text at
|
||||
[250 to 300 words per minute](http://www.paperbecause.com/PIOP/files/f7/f7bb6bc5-2c4a-466f-9ae7-b483a2c0dca4.pdf)
|
||||
(wpm). By contrast, the average rate of speech for English speakers is ~150 wpm,
|
||||
with slide presentations often closer to 100 wpm. As a result, when given the
|
||||
choice, many viewers
|
||||
[speed up video playback to ~1.3\~1.5 its recorded rate](http://research.microsoft.com/en-us/um/redmond/groups/coet/compression/chi99/paper.pdf)
|
||||
to compensate for the difference.
|
||||
|
||||
Many viewers report that
|
||||
[accelerated viewing keeps their attention longer](http://www.enounce.com/docs/BYUPaper020319.pdf):
|
||||
faster delivery keeps the viewer more engaged with the content. In fact, with a
|
||||
little training many end up watching videos at 2x+ the recorded speed. Some
|
||||
studies report that after being exposed to accelerated playback,
|
||||
[listeners become uncomfortable](http://alumni.media.mit.edu/~barons/html/avios92.html#beasleyalteredspeech)
|
||||
if they are forced to return to normal rate of presentation.
|
||||
|
||||
## Faster HTML5 Video
|
||||
|
||||
HTML5 video provides a native API to accelerate playback of any video. The problem is, many players either hide, or limit this functionality. For best results playback speed adjustments should be easy and frequent to match the pace and content being covered: we don't read at a fixed speed, and similarly, we need an easy way to accelerate the video, slow it down, and quickly rewind the last point to listen to it a few more times.
|
||||
HTML5 video provides a native API to accelerate playback of any video. The
|
||||
problem is, many players either hide, or limit this functionality. For best
|
||||
results playback speed adjustments should be easy and frequent to match the pace
|
||||
and content being covered: we don't read at a fixed speed, and similarly, we
|
||||
need an easy way to accelerate the video, slow it down, and quickly rewind the
|
||||
last point to listen to it a few more times.
|
||||
|
||||

|
||||
|
||||
#### *Install [Chrome](https://chrome.google.com/webstore/detail/video-speed-controller/nffaoalbilbmmfgbnbgppjihopabppdk) or [Firefox](https://addons.mozilla.org/en-us/firefox/addon/videospeed/) Extension*
|
||||
|
||||
Once the extension is installed simply navigate to any page that offers HTML5 video ([example](http://www.youtube.com/watch?v=E9FxNzv1Tr8)), and you'll see a speed indicator in top left corner. Hover over the indicator to reveal the controls to accelerate, slowdown, and quickly rewind or advance the video. Or, even better, simply use your keyboard:
|
||||
\*\* Once the extension is installed simply navigate to any page that offers
|
||||
HTML5 video ([example](http://www.youtube.com/watch?v=E9FxNzv1Tr8)), and you'll
|
||||
see a speed indicator in top left corner. Hover over the indicator to reveal the
|
||||
controls to accelerate, slowdown, and quickly rewind or advance the video. Or,
|
||||
even better, simply use your keyboard:
|
||||
|
||||
* **S** - decrease playback speed.
|
||||
* **D** - increase playback speed.
|
||||
* **R** - reset playback speed to 1.0x.
|
||||
* **Z** - rewind video by 10 seconds.
|
||||
* **X** - advance video by 10 seconds.
|
||||
* **G** - toggle between current and user configurable preferred speed.
|
||||
* **V** - show/hide the controller.
|
||||
- **S** - decrease playback speed.
|
||||
- **D** - increase playback speed.
|
||||
- **R** - reset playback speed to 1.0x.
|
||||
- **Z** - rewind video by 10 seconds.
|
||||
- **X** - advance video by 10 seconds.
|
||||
- **G** - toggle between current and user configurable preferred speed.
|
||||
- **V** - show/hide the controller.
|
||||
|
||||
You can customize and reassign the default shortcut keys in the extensions settings page, as well as add additional shortcut keys to match your preferences. For example, you can assign multiple different "preferred speed" shortcuts with different values, which will allow you to quickly toggle between your most commonly used speeds. To add a new shortcut, open extension settings and click "Add New".
|
||||
You can customize and reassign the default shortcut keys in the extensions
|
||||
settings page, as well as add additional shortcut keys to match your
|
||||
preferences. For example, you can assign multiple different "preferred speed"
|
||||
shortcuts with different values, which will allow you to quickly toggle between
|
||||
your most commonly used speeds. To add a new shortcut, open extension settings
|
||||
and click "Add New".
|
||||
|
||||

|
||||
|
||||
Some sites may assign other functionality to one of the assigned shortcut keys — these collisions are inevitable, unfortunately. As a workaround, the extension listens both for lower and upper case values (i.e. you can use `Shift-<shortcut>`) if there is other functionality assigned to the lowercase key. This is not a perfect solution, as some sites may listen to both, but works most of the time.
|
||||
Some sites may assign other functionality to one of the assigned shortcut keys —
|
||||
these collisions are inevitable, unfortunately. As a workaround, the extension
|
||||
listens both for lower and upper case values (i.e. you can use
|
||||
`Shift-<shortcut>`) if there is other functionality assigned to the lowercase
|
||||
key. This is not a perfect solution, as some sites may listen to both, but works
|
||||
most of the time.
|
||||
|
||||
### FAQ
|
||||
|
||||
**The video controls are not showing up?** This extension is only compatible with HTML5 video. If you don't see the controls showing up, chances are you are viewing a Flash video. If you want to confirm, try right-clicking on the video and inspect the menu: if it mentions flash, then that's the issue. That said, most sites will fallback to HTML5 if they detect that Flash is not available. You can try manually disabling Flash from the browser.
|
||||
**The video controls are not showing up?** This extension is only compatible
|
||||
with HTML5 video. If you don't see the controls showing up, chances are you are
|
||||
viewing a Flash video. If you want to confirm, try right-clicking on the video
|
||||
and inspect the menu: if it mentions flash, then that's the issue. That said,
|
||||
most sites will fallback to HTML5 if they detect that Flash is not available.
|
||||
You can try manually disabling Flash from the browser.
|
||||
|
||||
### License
|
||||
|
||||
|
21
inject.css
21
inject.css
@@ -1,8 +1,12 @@
|
||||
.vsc-nosource { display: none !important; }
|
||||
.vsc-hidden { display: none !important; }
|
||||
.vsc-nosource {
|
||||
display: none !important;
|
||||
}
|
||||
.vsc-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
.vsc-manual {
|
||||
visibility: visible !important;
|
||||
opacity: 1.0 !important;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
/* Origin specific overrides */
|
||||
@@ -14,13 +18,13 @@
|
||||
|
||||
.ytp-autohide .vsc-controller {
|
||||
visibility: hidden;
|
||||
transition: opacity .25s cubic-bezier(0.4,0,0.2,1);
|
||||
transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.ytp-autohide .vcs-show {
|
||||
visibility: visible;
|
||||
opacity: 1.0;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* YouTube embedded player */
|
||||
@@ -32,8 +36,8 @@
|
||||
|
||||
/* Facebook player */
|
||||
#facebook .vsc-controller {
|
||||
position: relative;
|
||||
top: 40px;
|
||||
position: relative;
|
||||
top: 40px;
|
||||
}
|
||||
|
||||
/* Google Photos player */
|
||||
@@ -76,7 +80,8 @@ div.video-wrapper + div.target {
|
||||
}
|
||||
|
||||
/* Fix black overlay on Kickstarter */
|
||||
div.video-player.has_played.vertically_center:before, div.legacy-video-player.has_played.vertically_center:before {
|
||||
div.video-player.has_played.vertically_center:before,
|
||||
div.legacy-video-player.has_played.vertically_center:before {
|
||||
content: none !important;
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "Video Speed Controller",
|
||||
"short_name": "videospeed",
|
||||
"version": "0.5.9.1",
|
||||
"version": "0.6.1",
|
||||
"manifest_version": 2,
|
||||
"description": "Speed up, slow down, advance and rewind any HTML5 video with quick shortcuts.",
|
||||
"description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts",
|
||||
"homepage_url": "https://github.com/codebicycle/videospeed",
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
@@ -15,7 +15,7 @@
|
||||
"48": "icons/icon48.png",
|
||||
"128": "icons/icon128.png"
|
||||
},
|
||||
"permissions": [ "activeTab", "storage" ],
|
||||
"permissions": ["activeTab", "storage"],
|
||||
"options_ui": {
|
||||
"page": "options.html",
|
||||
"open_in_tab": true
|
||||
@@ -28,22 +28,19 @@
|
||||
},
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
"content_scripts": [{
|
||||
"content_scripts": [
|
||||
{
|
||||
"all_frames": true,
|
||||
"matches": [ "http://*/*", "https://*/*", "file:///*" ],
|
||||
"matches": ["http://*/*", "https://*/*", "file:///*"],
|
||||
"match_about_blank": true,
|
||||
"exclude_matches": [
|
||||
"https://plus.google.com/hangouts/*",
|
||||
"https://hangouts.google.com/*",
|
||||
"https://meet.google.com/*",
|
||||
"https://teamtreehouse.com/*",
|
||||
"http://www.hitbox.tv/*"
|
||||
"https://meet.google.com/*"
|
||||
],
|
||||
"css": [ "inject.css" ],
|
||||
"js": [ "inject.js" ]
|
||||
"css": ["inject.css"],
|
||||
"js": ["inject.js"]
|
||||
}
|
||||
],
|
||||
"web_accessible_resources": [
|
||||
"inject.css", "shadow.css"
|
||||
]
|
||||
"web_accessible_resources": ["inject.css", "shadow.css"]
|
||||
}
|
||||
|
123
options.css
123
options.css
@@ -1,109 +1,112 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding-left: 15px;
|
||||
padding-top: 53px;
|
||||
font-family: sans-serif;
|
||||
font-size: 12px;
|
||||
color: rgb(48, 57, 66);
|
||||
margin: 0;
|
||||
padding-left: 15px;
|
||||
padding-top: 53px;
|
||||
font-family: sans-serif;
|
||||
font-size: 12px;
|
||||
color: rgb(48, 57, 66);
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-weight: normal;
|
||||
line-height: 1;
|
||||
user-select: none;
|
||||
cursor: default;
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
font-weight: normal;
|
||||
line-height: 1;
|
||||
user-select: none;
|
||||
cursor: default;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
margin: 21px 0 13px;
|
||||
font-size: 1.5em;
|
||||
margin: 21px 0 13px;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 0.8em;
|
||||
color: black;
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 0.8em;
|
||||
color: black;
|
||||
}
|
||||
p {
|
||||
margin: 0.65em 0;
|
||||
margin: 0.65em 0;
|
||||
}
|
||||
|
||||
header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 15px;
|
||||
right: 0;
|
||||
border-bottom: 1px solid #EEE;
|
||||
background: linear-gradient(white, white 40%, rgba(255, 255, 255, 0.92));
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 15px;
|
||||
right: 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
background: linear-gradient(white, white 40%, rgba(255, 255, 255, 0.92));
|
||||
}
|
||||
header, section {
|
||||
min-width: 600px;
|
||||
max-width: 738px;
|
||||
header,
|
||||
section {
|
||||
min-width: 600px;
|
||||
max-width: 738px;
|
||||
}
|
||||
section {
|
||||
padding-left: 18px;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 24px;
|
||||
padding-left: 18px;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
section h3 {
|
||||
margin-left: -18px;
|
||||
margin-left: -18px;
|
||||
}
|
||||
|
||||
button {
|
||||
-webkit-appearance: none;
|
||||
position: relative;
|
||||
-webkit-appearance: none;
|
||||
position: relative;
|
||||
|
||||
margin: 0 1px 0 0;
|
||||
padding: 0 10px;
|
||||
min-width: 4em;
|
||||
min-height: 2em;
|
||||
margin: 0 1px 0 0;
|
||||
padding: 0 10px;
|
||||
min-width: 4em;
|
||||
min-height: 2em;
|
||||
|
||||
background-image: linear-gradient(#EDEDED, #EDEDED 38%, #DEDEDE);
|
||||
border: 1px solid rgba(0,0,0,0.25);
|
||||
border-radius: 2px;
|
||||
outline: none;
|
||||
box-shadow: 0 1px 0 rgba(0,0,0,0.08), inset 0 1px 2px rgba(255,255,255,0.75);
|
||||
color: #444;
|
||||
text-shadow: 0 1px 0 rgb(240,240,240);
|
||||
font: inherit;
|
||||
background-image: linear-gradient(#ededed, #ededed 38%, #dedede);
|
||||
border: 1px solid rgba(0, 0, 0, 0.25);
|
||||
border-radius: 2px;
|
||||
outline: none;
|
||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08),
|
||||
inset 0 1px 2px rgba(255, 255, 255, 0.75);
|
||||
color: #444;
|
||||
text-shadow: 0 1px 0 rgb(240, 240, 240);
|
||||
font: inherit;
|
||||
|
||||
user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
||||
input[type="text"] {
|
||||
width: 75px;
|
||||
text-align: center;
|
||||
width: 75px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin: 5px 0px;
|
||||
margin: 5px 0px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline-block;
|
||||
width: 170px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
width: 170px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#status {
|
||||
color: #9D9D9D;
|
||||
display: inline-block;
|
||||
margin-left: 50px;
|
||||
color: #9d9d9d;
|
||||
display: inline-block;
|
||||
margin-left: 50px;
|
||||
}
|
||||
|
||||
#faq {
|
||||
margin-top: 2em;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
select {
|
||||
width: 170px;
|
||||
width: 170px;
|
||||
}
|
||||
|
||||
.customForce {
|
||||
display: none;
|
||||
width: 250px;
|
||||
display: none;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.customKey {
|
||||
color: transparent;
|
||||
text-shadow: 0 0 0 #000000;
|
||||
}
|
||||
}
|
||||
|
249
options.html
249
options.html
@@ -1,119 +1,170 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Video Speed Controller: Options</title>
|
||||
<link rel="stylesheet" href="options.css" />
|
||||
<script src="options.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Video Speed Controller</h1>
|
||||
</header>
|
||||
<head>
|
||||
<title>Video Speed Controller: Options</title>
|
||||
<link rel="stylesheet" href="options.css" />
|
||||
<script src="options.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Video Speed Controller</h1>
|
||||
</header>
|
||||
|
||||
<section id="customs">
|
||||
<h3>Shortcuts</h3>
|
||||
<div class="row customs" id="display">
|
||||
<select class="customDo">
|
||||
<option value="display">Show/hide controller</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" value="" placeholder="press a key">
|
||||
<input class="customValue" type="text" placeholder="value (0.10)">
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
</select></div>
|
||||
<div class="row customs" id="slower">
|
||||
<select class="customDo">
|
||||
<option value="slower">Decrease speed</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" value="" placeholder="press a key">
|
||||
<input class="customValue" type="text" placeholder="value (0.10)">
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
</select></div>
|
||||
<div class="row customs" id="faster">
|
||||
<select class="customDo">
|
||||
<option value="faster">Increase speed</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" value="" placeholder="press a key">
|
||||
<input class="customValue" type="text" placeholder="value (0.10)">
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
</select></div>
|
||||
<div class="row customs" id="rewind">
|
||||
<select class="customDo">
|
||||
<option value="rewind">Rewind</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" value="" placeholder="press a key">
|
||||
<input class="customValue" type="text" placeholder="value (10)">
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
</select></div>
|
||||
<div class="row customs" id="advance">
|
||||
<select class="customDo">
|
||||
<option value="advance">Advance</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" value="" placeholder="press a key">
|
||||
<input class="customValue" type="text" placeholder="value (10)">
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
</select></div>
|
||||
<div class="row customs" id="reset">
|
||||
<select class="customDo">
|
||||
<option value="reset">Reset speed</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" value="" placeholder="press a key">
|
||||
<input class="customValue" type="text" placeholder="value (1.00)" disabled>
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
</select></div>
|
||||
<div class="row customs" id="fast">
|
||||
<select class="customDo">
|
||||
<option value="fast">Preferred speed</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" value="" placeholder="press a key">
|
||||
<input class="customValue" type="text" placeholder="value (1.80)">
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
</select></div>
|
||||
<div class="row customs" id="display">
|
||||
<select class="customDo">
|
||||
<option value="display">Show/hide controller</option>
|
||||
</select>
|
||||
<input
|
||||
class="customKey"
|
||||
type="text"
|
||||
value=""
|
||||
placeholder="press a key"
|
||||
/>
|
||||
<input class="customValue" type="text" placeholder="value (0.10)" />
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row customs" id="slower">
|
||||
<select class="customDo">
|
||||
<option value="slower">Decrease speed</option>
|
||||
</select>
|
||||
<input
|
||||
class="customKey"
|
||||
type="text"
|
||||
value=""
|
||||
placeholder="press a key"
|
||||
/>
|
||||
<input class="customValue" type="text" placeholder="value (0.10)" />
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row customs" id="faster">
|
||||
<select class="customDo">
|
||||
<option value="faster">Increase speed</option>
|
||||
</select>
|
||||
<input
|
||||
class="customKey"
|
||||
type="text"
|
||||
value=""
|
||||
placeholder="press a key"
|
||||
/>
|
||||
<input class="customValue" type="text" placeholder="value (0.10)" />
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row customs" id="rewind">
|
||||
<select class="customDo">
|
||||
<option value="rewind">Rewind</option>
|
||||
</select>
|
||||
<input
|
||||
class="customKey"
|
||||
type="text"
|
||||
value=""
|
||||
placeholder="press a key"
|
||||
/>
|
||||
<input class="customValue" type="text" placeholder="value (10)" />
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row customs" id="advance">
|
||||
<select class="customDo">
|
||||
<option value="advance">Advance</option>
|
||||
</select>
|
||||
<input
|
||||
class="customKey"
|
||||
type="text"
|
||||
value=""
|
||||
placeholder="press a key"
|
||||
/>
|
||||
<input class="customValue" type="text" placeholder="value (10)" />
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row customs" id="reset">
|
||||
<select class="customDo">
|
||||
<option value="reset">Reset speed</option>
|
||||
</select>
|
||||
<input
|
||||
class="customKey"
|
||||
type="text"
|
||||
value=""
|
||||
placeholder="press a key"
|
||||
/>
|
||||
<input
|
||||
class="customValue"
|
||||
type="text"
|
||||
placeholder="value (1.00)"
|
||||
disabled
|
||||
/>
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row customs" id="fast">
|
||||
<select class="customDo">
|
||||
<option value="fast">Preferred speed</option>
|
||||
</select>
|
||||
<input
|
||||
class="customKey"
|
||||
type="text"
|
||||
value=""
|
||||
placeholder="press a key"
|
||||
/>
|
||||
<input class="customValue" type="text" placeholder="value (1.80)" />
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button id="add">Add New</button>
|
||||
<button id="add">Add New</button>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3>Other</h3>
|
||||
<div class="row">
|
||||
<label for="enabled">Enabled</label>
|
||||
<input id="enabled" type="checkbox"/>
|
||||
<label for="enabled">Enable</label>
|
||||
<input id="enabled" type="checkbox" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="startHidden">Hide controller by default</label>
|
||||
<input id="startHidden" type="checkbox"/>
|
||||
<input id="startHidden" type="checkbox" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="rememberSpeed">Remember Playback Speed</label>
|
||||
<input id="rememberSpeed" type="checkbox"/>
|
||||
<label for="rememberSpeed">Remember playback speed</label>
|
||||
<input id="rememberSpeed" type="checkbox" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="audioBoolean">Work on audio</label>
|
||||
<input id="audioBoolean" type="checkbox"/>
|
||||
<input id="audioBoolean" type="checkbox" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="controllerOpacity">Controller opacity</label>
|
||||
<input id="controllerOpacity" type="text" value="">
|
||||
<input id="controllerOpacity" type="text" value="" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="blacklist">Blacklisted sites on which extension is disabled<br/>
|
||||
(one per line)<br/>
|
||||
<br/>
|
||||
<em><a href="https://www.regexpal.com/">Regex</a> is supported. Be sure it is in "//g" format.<br/>
|
||||
ie: /(.+)youtube\.com(\/*)$/gi</em>
|
||||
<label for="blacklist"
|
||||
>Sites on which extension is disabled<br />
|
||||
(one per line)<br />
|
||||
<br />
|
||||
<em>
|
||||
<a href="https://www.regexpal.com/">Regex</a> is supported.<br />
|
||||
Be sure it is in "//g" format.<br />
|
||||
ie: /(.+)youtube\.com(\/*)$/gi
|
||||
</em>
|
||||
</label>
|
||||
<textarea id="blacklist" rows="10" cols="50"></textarea>
|
||||
</div>
|
||||
@@ -121,16 +172,22 @@
|
||||
|
||||
<button id="save">Save</button>
|
||||
<button id="restore">Restore Defaults</button>
|
||||
<button id="experimental">Show experimental features</button>
|
||||
<button id="experimental">Show Experimental Features</button>
|
||||
|
||||
<div id="status"></div>
|
||||
|
||||
<div id="faq">
|
||||
<hr />
|
||||
|
||||
<h4>The video controls are not showing up?</h4>
|
||||
<p>This extension is only compatible with HTML5 video. If you don't see the controls showing up, chances are you are viewing a Flash video. If you want to confirm, try right-clicking on the video and inspect the menu: if it mentions flash, then that's the issue. That said, <b>most sites will fallback to HTML5</b> if they detect that Flash is not available. You can try manually disabling Flash from the browser.</p>
|
||||
|
||||
<h4>Extension controls not appearing?</h4>
|
||||
<p>
|
||||
This extension is only compatible with HTML5 audio and video. If you don't
|
||||
see the controls showing up, chances are you are viewing a Flash content.
|
||||
If you want to confirm, try right-clicking on the content and inspect the
|
||||
menu: if it mentions flash, then that's the issue. That said, <b>most sites
|
||||
will fallback to HTML5</b> if they detect that Flash is not available. You
|
||||
can try manually disabling Flash from the browser.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
400
options.js
400
options.js
@@ -1,103 +1,105 @@
|
||||
var regStrip=/^[\r\t\f\v ]+|[\r\t\f\v ]+$/gm;
|
||||
var regStrip = /^[\r\t\f\v ]+|[\r\t\f\v ]+$/gm;
|
||||
|
||||
var tcDefaults = {
|
||||
speed: 1.0, // default:
|
||||
displayKeyCode: 86, // default: V
|
||||
speed: 1.0, // default:
|
||||
displayKeyCode: 86, // default: V
|
||||
rememberSpeed: false, // default: false
|
||||
audioBoolean: false, // default: false
|
||||
startHidden: false, // default: false
|
||||
enabled: true, // default enabled
|
||||
startHidden: false, // default: false
|
||||
enabled: true, // default enabled
|
||||
controllerOpacity: 0.3, // default: 0.3
|
||||
keyBindings: [
|
||||
{action: "display", key: 86, value: 0, force: false, predefined: true }, // V
|
||||
{action: "slower", key: 83, value: 0.1, force: false, predefined: true}, // S
|
||||
{action: "faster", key: 68, value: 0.1, force: false, predefined: true}, // D
|
||||
{action: "rewind", key: 90, value: 10, force: false, predefined: true}, // Z
|
||||
{action: "advance", key: 88, value: 10, force: false, predefined: true}, // X
|
||||
{action: "reset", key: 82, value: 1, force: false, predefined: true}, // R
|
||||
{action: "fast", key: 71, value: 1.8, force: false, predefined: true} // G
|
||||
{ action: "display", key: 86, value: 0, force: false, predefined: true }, // V
|
||||
{ action: "slower", key: 83, value: 0.1, force: false, predefined: true }, // S
|
||||
{ action: "faster", key: 68, value: 0.1, force: false, predefined: true }, // D
|
||||
{ action: "rewind", key: 90, value: 10, force: false, predefined: true }, // Z
|
||||
{ action: "advance", key: 88, value: 10, force: false, predefined: true }, // X
|
||||
{ action: "reset", key: 82, value: 1, force: false, predefined: true }, // R
|
||||
{ action: "fast", key: 71, value: 1.8, force: false, predefined: true } // G
|
||||
],
|
||||
blacklist: `
|
||||
www.instagram.com
|
||||
blacklist:
|
||||
`www.instagram.com
|
||||
twitter.com
|
||||
vine.co
|
||||
imgur.com
|
||||
teams.microsoft.com
|
||||
`.replace(regStrip, '')
|
||||
`.replace(regStrip, "")
|
||||
};
|
||||
|
||||
var keyBindings = [];
|
||||
|
||||
var keyCodeAliases = {
|
||||
0: 'null',
|
||||
null: 'null',
|
||||
undefined: 'null',
|
||||
32: 'Space',
|
||||
37: 'Left',
|
||||
38: 'Up',
|
||||
39: 'Right',
|
||||
40: 'Down',
|
||||
96: 'Num 0',
|
||||
97: 'Num 1',
|
||||
98: 'Num 2',
|
||||
99: 'Num 3',
|
||||
100: 'Num 4',
|
||||
101: 'Num 5',
|
||||
102: 'Num 6',
|
||||
103: 'Num 7',
|
||||
104: 'Num 8',
|
||||
105: 'Num 9',
|
||||
106: 'Num *',
|
||||
107: 'Num +',
|
||||
109: 'Num -',
|
||||
110: 'Num .',
|
||||
111: 'Num /',
|
||||
112: 'F1',
|
||||
113: 'F2',
|
||||
114: 'F3',
|
||||
115: 'F4',
|
||||
116: 'F5',
|
||||
117: 'F6',
|
||||
118: 'F7',
|
||||
119: 'F8',
|
||||
120: 'F9',
|
||||
121: 'F10',
|
||||
122: 'F11',
|
||||
123: 'F12',
|
||||
186: ';',
|
||||
188: '<',
|
||||
189: '-',
|
||||
187: '+',
|
||||
190: '>',
|
||||
191: '/',
|
||||
192: '~',
|
||||
219: '[',
|
||||
220: '\\',
|
||||
221: ']',
|
||||
222: '\'',
|
||||
59: ';',
|
||||
61: '+',
|
||||
173: '-',
|
||||
}
|
||||
0: "null",
|
||||
null: "null",
|
||||
undefined: "null",
|
||||
32: "Space",
|
||||
37: "Left",
|
||||
38: "Up",
|
||||
39: "Right",
|
||||
40: "Down",
|
||||
96: "Num 0",
|
||||
97: "Num 1",
|
||||
98: "Num 2",
|
||||
99: "Num 3",
|
||||
100: "Num 4",
|
||||
101: "Num 5",
|
||||
102: "Num 6",
|
||||
103: "Num 7",
|
||||
104: "Num 8",
|
||||
105: "Num 9",
|
||||
106: "Num *",
|
||||
107: "Num +",
|
||||
109: "Num -",
|
||||
110: "Num .",
|
||||
111: "Num /",
|
||||
112: "F1",
|
||||
113: "F2",
|
||||
114: "F3",
|
||||
115: "F4",
|
||||
116: "F5",
|
||||
117: "F6",
|
||||
118: "F7",
|
||||
119: "F8",
|
||||
120: "F9",
|
||||
121: "F10",
|
||||
122: "F11",
|
||||
123: "F12",
|
||||
186: ";",
|
||||
188: "<",
|
||||
189: "-",
|
||||
187: "+",
|
||||
190: ">",
|
||||
191: "/",
|
||||
192: "~",
|
||||
219: "[",
|
||||
220: "\\",
|
||||
221: "]",
|
||||
222: "'",
|
||||
59: ";",
|
||||
61: "+",
|
||||
173: "-",
|
||||
};
|
||||
|
||||
function recordKeyPress(e) {
|
||||
if (
|
||||
(e.keyCode >= 48 && e.keyCode <= 57) // Numbers 0-9
|
||||
|| (e.keyCode >= 65 && e.keyCode <= 90) // Letters A-Z
|
||||
|| keyCodeAliases[e.keyCode] // Other character keys
|
||||
(e.keyCode >= 48 && e.keyCode <= 57) || // Numbers 0-9
|
||||
(e.keyCode >= 65 && e.keyCode <= 90) || // Letters A-Z
|
||||
keyCodeAliases[e.keyCode] // Other character keys
|
||||
) {
|
||||
e.target.value = keyCodeAliases[e.keyCode] || String.fromCharCode(e.keyCode);
|
||||
e.target.value =
|
||||
keyCodeAliases[e.keyCode] || String.fromCharCode(e.keyCode);
|
||||
e.target.keyCode = e.keyCode;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
} else if (e.keyCode === 8) { // Clear input when backspace pressed
|
||||
e.target.value = '';
|
||||
} else if (e.keyCode === 27) { // When esc clicked, clear input
|
||||
e.target.value = 'null';
|
||||
} else if (e.keyCode === 8) {
|
||||
// Clear input when backspace pressed
|
||||
e.target.value = "";
|
||||
} else if (e.keyCode === 27) {
|
||||
// When esc clicked, clear input
|
||||
e.target.value = "null";
|
||||
e.target.keyCode = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function inputFilterNumbersOnly(e) {
|
||||
var char = String.fromCharCode(e.keyCode);
|
||||
@@ -105,18 +107,20 @@ function inputFilterNumbersOnly(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function inputFocus(e) {
|
||||
e.target.value = "";
|
||||
};
|
||||
e.target.value = "";
|
||||
}
|
||||
|
||||
function inputBlur(e) {
|
||||
e.target.value = keyCodeAliases[e.target.keyCode] || String.fromCharCode(e.target.keyCode);
|
||||
};
|
||||
e.target.value =
|
||||
keyCodeAliases[e.target.keyCode] || String.fromCharCode(e.target.keyCode);
|
||||
}
|
||||
|
||||
function updateShortcutInputText(inputId, keyCode) {
|
||||
document.getElementById(inputId).value = keyCodeAliases[keyCode] || String.fromCharCode(keyCode);
|
||||
document.getElementById(inputId).value =
|
||||
keyCodeAliases[keyCode] || String.fromCharCode(keyCode);
|
||||
document.getElementById(inputId).keyCode = keyCode;
|
||||
}
|
||||
|
||||
@@ -126,7 +130,7 @@ function updateCustomShortcutInputText(inputItem, keyCode) {
|
||||
}
|
||||
|
||||
// List of custom actions for which customValue should be disabled
|
||||
var customActionsNoValues=["pause","muted","mark","jump","display"];
|
||||
var customActionsNoValues = ["pause", "muted", "mark", "jump", "display"];
|
||||
|
||||
function add_shortcut() {
|
||||
var html = `<select class="customDo">
|
||||
@@ -141,19 +145,22 @@ function add_shortcut() {
|
||||
<option value="mark">Set marker</option>
|
||||
<option value="jump">Jump to marker</option>
|
||||
<option value="display">Show/hide controller</option>
|
||||
</select>
|
||||
<input class="customKey" type="text" placeholder="press a key"/>
|
||||
<input class="customValue" type="text" placeholder="value (0.10)"/>
|
||||
</select>
|
||||
<input class="customKey" type="text" placeholder="press a key"/>
|
||||
<input class="customValue" type="text" placeholder="value (0.10)"/>
|
||||
<select class="customForce">
|
||||
<option value="false">Do not disable website key bindings</option>
|
||||
<option value="true">Disable websites key bindings</option>
|
||||
<option value="true">Disable website key bindings</option>
|
||||
</select>
|
||||
<button class="removeParent">X</button>`;
|
||||
var div = document.createElement('div');
|
||||
div.setAttribute('class', 'row customs');
|
||||
var div = document.createElement("div");
|
||||
div.setAttribute("class", "row customs");
|
||||
div.innerHTML = html;
|
||||
var customs_element = document.getElementById("customs");
|
||||
customs_element.insertBefore(div, customs_element.children[customs_element.childElementCount - 1]);
|
||||
customs_element.insertBefore(
|
||||
div,
|
||||
customs_element.children[customs_element.childElementCount - 1]
|
||||
);
|
||||
}
|
||||
|
||||
function createKeyBindings(item) {
|
||||
@@ -161,28 +168,37 @@ function createKeyBindings(item) {
|
||||
const key = item.querySelector(".customKey").keyCode;
|
||||
const value = Number(item.querySelector(".customValue").value);
|
||||
const force = item.querySelector(".customForce").value;
|
||||
const predefined = !!item.id;//item.id ? true : false;
|
||||
const predefined = !!item.id; //item.id ? true : false;
|
||||
|
||||
keyBindings.push({action: action, key: key, value: value, force: force, predefined: predefined});
|
||||
keyBindings.push({
|
||||
action: action,
|
||||
key: key,
|
||||
value: value,
|
||||
force: force,
|
||||
predefined: predefined
|
||||
});
|
||||
}
|
||||
|
||||
// Validates settings before saving
|
||||
function validate() {
|
||||
var valid = true;
|
||||
var status = document.getElementById('status');
|
||||
document.getElementById('blacklist').value.split("\n").forEach(match => {
|
||||
match = match.replace(regStrip,'')
|
||||
if (match.startsWith('/')) {
|
||||
try {
|
||||
var regexp = new RegExp(match);
|
||||
} catch(err) {
|
||||
status.textContent = 'Error: Invalid Regex: ' + match
|
||||
+ '. Unable to save';
|
||||
valid = false;
|
||||
return;
|
||||
var status = document.getElementById("status");
|
||||
document
|
||||
.getElementById("blacklist")
|
||||
.value.split("\n")
|
||||
.forEach(match => {
|
||||
match = match.replace(regStrip, "");
|
||||
if (match.startsWith("/")) {
|
||||
try {
|
||||
var regexp = new RegExp(match);
|
||||
} catch (err) {
|
||||
status.textContent =
|
||||
"Error: Invalid blacklist regex: " + match + ". Unable to save";
|
||||
valid = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
return valid;
|
||||
}
|
||||
|
||||
@@ -192,47 +208,70 @@ function save_options() {
|
||||
return;
|
||||
}
|
||||
keyBindings = [];
|
||||
Array.from(document.querySelectorAll(".customs")).forEach(item => createKeyBindings(item)); // Remove added shortcuts
|
||||
Array.from(document.querySelectorAll(".customs")).forEach(item =>
|
||||
createKeyBindings(item)
|
||||
); // Remove added shortcuts
|
||||
|
||||
var rememberSpeed = document.getElementById('rememberSpeed').checked;
|
||||
var audioBoolean = document.getElementById('audioBoolean').checked;
|
||||
var enabled = document.getElementById('enabled').checked;
|
||||
var startHidden = document.getElementById('startHidden').checked;
|
||||
var controllerOpacity = document.getElementById('controllerOpacity').value;
|
||||
var blacklist = document.getElementById('blacklist').value;
|
||||
var rememberSpeed = document.getElementById("rememberSpeed").checked;
|
||||
var audioBoolean = document.getElementById("audioBoolean").checked;
|
||||
var enabled = document.getElementById("enabled").checked;
|
||||
var startHidden = document.getElementById("startHidden").checked;
|
||||
var controllerOpacity = document.getElementById("controllerOpacity").value;
|
||||
var blacklist = document.getElementById("blacklist").value;
|
||||
|
||||
chrome.storage.sync.remove(["resetSpeed", "speedStep", "fastSpeed", "rewindTime", "advanceTime", "resetKeyCode", "slowerKeyCode", "fasterKeyCode", "rewindKeyCode", "advanceKeyCode", "fastKeyCode"]);
|
||||
chrome.storage.sync.set({
|
||||
rememberSpeed: rememberSpeed,
|
||||
audioBoolean: audioBoolean,
|
||||
enabled: enabled,
|
||||
startHidden: startHidden,
|
||||
controllerOpacity: controllerOpacity,
|
||||
keyBindings: keyBindings,
|
||||
blacklist: blacklist.replace(regStrip,'')
|
||||
}, function() {
|
||||
// Update status to let user know options were saved.
|
||||
var status = document.getElementById('status');
|
||||
status.textContent = 'Options saved';
|
||||
setTimeout(function() {
|
||||
status.textContent = '';
|
||||
}, 1000);
|
||||
});
|
||||
chrome.storage.sync.remove([
|
||||
"resetSpeed",
|
||||
"speedStep",
|
||||
"fastSpeed",
|
||||
"rewindTime",
|
||||
"advanceTime",
|
||||
"resetKeyCode",
|
||||
"slowerKeyCode",
|
||||
"fasterKeyCode",
|
||||
"rewindKeyCode",
|
||||
"advanceKeyCode",
|
||||
"fastKeyCode"
|
||||
]);
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
rememberSpeed: rememberSpeed,
|
||||
audioBoolean: audioBoolean,
|
||||
enabled: enabled,
|
||||
startHidden: startHidden,
|
||||
controllerOpacity: controllerOpacity,
|
||||
keyBindings: keyBindings,
|
||||
blacklist: blacklist.replace(regStrip, "")
|
||||
},
|
||||
function() {
|
||||
// Update status to let user know options were saved.
|
||||
var status = document.getElementById("status");
|
||||
status.textContent = "Options saved";
|
||||
setTimeout(function() {
|
||||
status.textContent = "";
|
||||
}, 1000);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Restores options from chrome.storage
|
||||
function restore_options() {
|
||||
chrome.storage.sync.get(tcDefaults, function(storage) {
|
||||
document.getElementById('rememberSpeed').checked = storage.rememberSpeed;
|
||||
document.getElementById('audioBoolean').checked = storage.audioBoolean;
|
||||
document.getElementById('enabled').checked = storage.enabled;
|
||||
document.getElementById('startHidden').checked = storage.startHidden;
|
||||
document.getElementById('controllerOpacity').value = storage.controllerOpacity;
|
||||
document.getElementById('blacklist').value = storage.blacklist;
|
||||
document.getElementById("rememberSpeed").checked = storage.rememberSpeed;
|
||||
document.getElementById("audioBoolean").checked = storage.audioBoolean;
|
||||
document.getElementById("enabled").checked = storage.enabled;
|
||||
document.getElementById("startHidden").checked = storage.startHidden;
|
||||
document.getElementById("controllerOpacity").value =
|
||||
storage.controllerOpacity;
|
||||
document.getElementById("blacklist").value = storage.blacklist;
|
||||
|
||||
// ensure that there is a "display" binding for upgrades from versions that had it as a separate binding
|
||||
if(storage.keyBindings.filter(x => x.action == "display").length == 0){
|
||||
storage.keyBindings.push({ action: "display", value: 0, force: false, predefined: true });
|
||||
if (storage.keyBindings.filter(x => x.action == "display").length == 0) {
|
||||
storage.keyBindings.push({
|
||||
action: "display",
|
||||
value: 0,
|
||||
force: false,
|
||||
predefined: true
|
||||
});
|
||||
}
|
||||
|
||||
for (let i in storage.keyBindings) {
|
||||
@@ -240,27 +279,36 @@ function restore_options() {
|
||||
if (item.predefined) {
|
||||
//do predefined ones because their value needed for overlay
|
||||
// document.querySelector("#" + item["action"] + " .customDo").value = item["action"];
|
||||
if (item["action"] == "display" && typeof (item["key"]) === "undefined"){
|
||||
if (item["action"] == "display" && typeof item["key"] === "undefined") {
|
||||
item["key"] = storage.displayKeyCode || tcDefaults.displayKeyCode; // V
|
||||
}
|
||||
|
||||
if (customActionsNoValues.includes(item["action"]))
|
||||
document.querySelector("#" + item["action"] + " .customValue").disabled = true;
|
||||
document.querySelector(
|
||||
"#" + item["action"] + " .customValue"
|
||||
).disabled = true;
|
||||
|
||||
updateCustomShortcutInputText(document.querySelector("#" + item["action"] + " .customKey"), item["key"]);
|
||||
document.querySelector("#" + item["action"] + " .customValue").value = item["value"];
|
||||
document.querySelector("#" + item["action"] + " .customForce").value = item["force"];
|
||||
}
|
||||
else {
|
||||
updateCustomShortcutInputText(
|
||||
document.querySelector("#" + item["action"] + " .customKey"),
|
||||
item["key"]
|
||||
);
|
||||
document.querySelector("#" + item["action"] + " .customValue").value =
|
||||
item["value"];
|
||||
document.querySelector("#" + item["action"] + " .customForce").value =
|
||||
item["force"];
|
||||
} else {
|
||||
// new ones
|
||||
add_shortcut();
|
||||
const dom = document.querySelector(".customs:last-of-type")
|
||||
const dom = document.querySelector(".customs:last-of-type");
|
||||
dom.querySelector(".customDo").value = item["action"];
|
||||
|
||||
if (customActionsNoValues.includes(item["action"]))
|
||||
dom.querySelector(".customValue").disabled = true;
|
||||
|
||||
updateCustomShortcutInputText(dom.querySelector(".customKey"), item["key"]);
|
||||
updateCustomShortcutInputText(
|
||||
dom.querySelector(".customKey"),
|
||||
item["key"]
|
||||
);
|
||||
dom.querySelector(".customValue").value = item["value"];
|
||||
dom.querySelector(".customForce").value = item["force"];
|
||||
}
|
||||
@@ -271,60 +319,68 @@ function restore_options() {
|
||||
function restore_defaults() {
|
||||
chrome.storage.sync.set(tcDefaults, function() {
|
||||
restore_options();
|
||||
document.querySelectorAll(".removeParent").forEach(button => button.click()); // Remove added shortcuts
|
||||
document
|
||||
.querySelectorAll(".removeParent")
|
||||
.forEach(button => button.click()); // Remove added shortcuts
|
||||
// Update status to let user know options were saved.
|
||||
var status = document.getElementById('status');
|
||||
status.textContent = 'Default options restored';
|
||||
var status = document.getElementById("status");
|
||||
status.textContent = "Default options restored";
|
||||
setTimeout(function() {
|
||||
status.textContent = '';
|
||||
status.textContent = "";
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
function show_experimental() {
|
||||
document.querySelectorAll(".customForce").forEach(item => item.style.display = 'inline-block');
|
||||
document
|
||||
.querySelectorAll(".customForce")
|
||||
.forEach(item => (item.style.display = "inline-block"));
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
restore_options();
|
||||
|
||||
document.getElementById('save').addEventListener('click', save_options);
|
||||
document.getElementById('add').addEventListener('click', add_shortcut);
|
||||
document.getElementById('restore').addEventListener('click', restore_defaults);
|
||||
document.getElementById('experimental').addEventListener('click', show_experimental);
|
||||
document.getElementById("save").addEventListener("click", save_options);
|
||||
document.getElementById("add").addEventListener("click", add_shortcut);
|
||||
document
|
||||
.getElementById("restore")
|
||||
.addEventListener("click", restore_defaults);
|
||||
document
|
||||
.getElementById("experimental")
|
||||
.addEventListener("click", show_experimental);
|
||||
|
||||
function eventCaller(event, className, funcName) {
|
||||
if (!event.target.classList.contains(className)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
funcName(event);
|
||||
}
|
||||
|
||||
document.addEventListener('keypress', (event) => {
|
||||
eventCaller(event, "customValue", inputFilterNumbersOnly)
|
||||
document.addEventListener("keypress", event => {
|
||||
eventCaller(event, "customValue", inputFilterNumbersOnly);
|
||||
});
|
||||
document.addEventListener('focus', (event) => {
|
||||
eventCaller(event, "customKey", inputFocus)
|
||||
document.addEventListener("focus", event => {
|
||||
eventCaller(event, "customKey", inputFocus);
|
||||
});
|
||||
document.addEventListener('blur', (event) => {
|
||||
eventCaller(event, "customKey", inputBlur)
|
||||
document.addEventListener("blur", event => {
|
||||
eventCaller(event, "customKey", inputBlur);
|
||||
});
|
||||
document.addEventListener('keydown', (event) => {
|
||||
eventCaller(event, "customKey", recordKeyPress)
|
||||
document.addEventListener("keydown", event => {
|
||||
eventCaller(event, "customKey", recordKeyPress);
|
||||
});
|
||||
document.addEventListener('click', (event) => {
|
||||
eventCaller(event, "removeParent", function () {
|
||||
event.target.parentNode.remove()
|
||||
})
|
||||
document.addEventListener("click", event => {
|
||||
eventCaller(event, "removeParent", function() {
|
||||
event.target.parentNode.remove();
|
||||
});
|
||||
});
|
||||
document.addEventListener('change', (event) => {
|
||||
eventCaller(event, "customDo", function () {
|
||||
document.addEventListener("change", event => {
|
||||
eventCaller(event, "customDo", function() {
|
||||
if (customActionsNoValues.includes(event.target.value)) {
|
||||
event.target.nextElementSibling.nextElementSibling.disabled = true;
|
||||
event.target.nextElementSibling.nextElementSibling.value = 0;
|
||||
} else {
|
||||
event.target.nextElementSibling.nextElementSibling.disabled = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
11
popup.css
11
popup.css
@@ -1,5 +1,5 @@
|
||||
body {
|
||||
min-width: 8em
|
||||
min-width: 8em;
|
||||
}
|
||||
|
||||
hr {
|
||||
@@ -12,13 +12,14 @@ hr {
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
background-image: linear-gradient(#EDEDED, #EDEDED 38%, #DEDEDE);
|
||||
border: 1px solid rgba(0,0,0,0.25);
|
||||
background-image: linear-gradient(#ededed, #ededed 38%, #dedede);
|
||||
border: 1px solid rgba(0, 0, 0, 0.25);
|
||||
border-radius: 2px;
|
||||
outline: none;
|
||||
box-shadow: 0 1px 0 rgba(0,0,0,0.08), inset 0 1px 2px rgba(255,255,255,0.75);
|
||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08),
|
||||
inset 0 1px 2px rgba(255, 255, 255, 0.75);
|
||||
color: #444;
|
||||
text-shadow: 0 1px 0 rgb(240,240,240);
|
||||
text-shadow: 0 1px 0 rgb(240, 240, 240);
|
||||
font: inherit;
|
||||
user-select: none;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Video Speed Controller: Popup</title>
|
||||
|
51
popup.js
51
popup.js
@@ -1,5 +1,5 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelector('#config').addEventListener('click', function() {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.querySelector("#config").addEventListener("click", function() {
|
||||
window.open(chrome.runtime.getURL("options.html"));
|
||||
});
|
||||
|
||||
@@ -11,34 +11,37 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
window.open("https://github.com/codebicycle/videospeed/issues");
|
||||
});
|
||||
|
||||
document.querySelector('#enable').addEventListener('click', function() {
|
||||
toggleEnabled(true, settingsSavedReloadMessage);
|
||||
document.querySelector("#enable").addEventListener("click", function() {
|
||||
toggleEnabled(true, settingsSavedReloadMessage);
|
||||
});
|
||||
|
||||
document.querySelector('#disable').addEventListener('click', function() {
|
||||
toggleEnabled(false, settingsSavedReloadMessage);
|
||||
document.querySelector("#disable").addEventListener("click", function() {
|
||||
toggleEnabled(false, settingsSavedReloadMessage);
|
||||
});
|
||||
|
||||
chrome.storage.sync.get({enabled: true}, function(storage) {
|
||||
chrome.storage.sync.get({ enabled: true }, function(storage) {
|
||||
toggleEnabledUI(storage.enabled);
|
||||
});
|
||||
|
||||
function toggleEnabled(enabled, callback){
|
||||
chrome.storage.sync.set({
|
||||
enabled: enabled,
|
||||
}, function() {
|
||||
toggleEnabledUI(enabled);
|
||||
if(callback) callback(enabled);
|
||||
});
|
||||
function toggleEnabled(enabled, callback) {
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
enabled: enabled
|
||||
},
|
||||
function() {
|
||||
toggleEnabledUI(enabled);
|
||||
if (callback) callback(enabled);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function toggleEnabledUI(enabled){
|
||||
document.querySelector('#enable').classList.toggle("hide", enabled);
|
||||
document.querySelector('#disable').classList.toggle("hide", !enabled);
|
||||
function toggleEnabledUI(enabled) {
|
||||
document.querySelector("#enable").classList.toggle("hide", enabled);
|
||||
document.querySelector("#disable").classList.toggle("hide", !enabled);
|
||||
|
||||
const suffix = `${(enabled ? "" : "_disabled")}.png`
|
||||
const suffix = `${enabled ? "" : "_disabled"}.png`;
|
||||
chrome.browserAction.setIcon({
|
||||
"path": {
|
||||
path: {
|
||||
"19": "icons/icon19" + suffix,
|
||||
"38": "icons/icon38" + suffix,
|
||||
"48": "icons/icon48" + suffix
|
||||
@@ -46,12 +49,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
});
|
||||
}
|
||||
|
||||
function settingsSavedReloadMessage(enabled){
|
||||
setStatusMessage(`${enabled ? "Enabled" : "Disabled"}. Reload page to see changes`);
|
||||
function settingsSavedReloadMessage(enabled) {
|
||||
setStatusMessage(
|
||||
`${enabled ? "Enabled" : "Disabled"}. Reload page to see changes`
|
||||
);
|
||||
}
|
||||
|
||||
function setStatusMessage(str){
|
||||
const status_element = document.querySelector('#status')
|
||||
function setStatusMessage(str) {
|
||||
const status_element = document.querySelector("#status");
|
||||
status_element.classList.toggle("hide", false);
|
||||
status_element.innerText = str;
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ button:focus {
|
||||
}
|
||||
|
||||
button:hover {
|
||||
opacity: 1.0;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
button:active {
|
||||
|
Reference in New Issue
Block a user