mirror of
https://github.com/SoPat712/videospeed.git
synced 2026-04-23 05:12:37 -04:00
Compare commits
121 Commits
v1.1.3
...
v5.1.6-beta.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
1536c13c3e
|
|||
|
6bd319c8cc
|
|||
|
3aee8c8f9a
|
|||
|
939ee08466
|
|||
|
5a175c3cf8
|
|||
|
805e5a82e5
|
|||
|
df34b1fee9
|
|||
|
0741c6e535
|
|||
|
fad0c49e65
|
|||
|
66075fb6f3
|
|||
|
bf4025dcb4
|
|||
|
76a7b933bb
|
|||
|
1cd533fc5c
|
|||
|
8c5bd68d39
|
|||
|
9c257af446
|
|||
|
64a9b85587
|
|||
|
edd997037a
|
|||
|
f85a1f9f29
|
|||
|
97366b76b6
|
|||
|
8269875bb1
|
|||
|
e34ec17f33
|
|||
|
8d3905b654
|
|||
|
7fd8a931d8
|
|||
|
17319c1e25
|
|||
|
841c1a246e
|
|||
|
ed0f63e8bc
|
|||
|
53f66f1eeb
|
|||
|
f106ab490a
|
|||
|
5a38121e09
|
|||
|
36ed922b5c
|
|||
|
3275d1f322
|
|||
|
f6d706f096
|
|||
|
04292a8018
|
|||
|
8eb3901121
|
|||
|
0bcca24241
|
|||
|
6bf48fa479
|
|||
|
9b4f338ebb
|
|||
|
3a583ce3b8
|
|||
|
06f40b3d6d
|
|||
|
5c20d7ae0b
|
|||
|
068e65f62f
|
|||
|
b0498cd1d7
|
|||
|
52080a4185
|
|||
|
85215ae54b
|
|||
|
9f8c235cea
|
|||
|
30c5a7dbe3
|
|||
|
597c7a8af5
|
|||
|
d215ad4224
|
|||
|
705667b532
|
|||
|
df18e638c2
|
|||
|
9ff3ce4f74
|
|||
|
11e3518902
|
|||
|
91dc47f5a8
|
|||
|
36a60bbe34
|
|||
|
ea48170e11
|
|||
|
3bcb36f6d0
|
|||
|
f2cf8b6205
|
|||
|
2747c15924
|
|||
|
5e7d5d6d21
|
|||
|
6045ac5688
|
|||
|
38174a2a76
|
|||
|
8569fa6e33
|
|||
|
30ba6585b0
|
|||
|
8d48dcccca
|
|||
|
75acaada8d
|
|||
|
6d993edf50
|
|||
|
b4030f91dd
|
|||
|
44c9c576ed
|
|||
|
72f590cd02
|
|||
|
caf75b3e54
|
|||
|
37d1831b8b
|
|||
|
14e37c62d5
|
|||
|
03f5dbaa96
|
|||
|
8b30005fb2
|
|||
|
f385074905
|
|||
|
a51801e7c3
|
|||
|
cd5e4bee9f
|
|||
|
4d34c8754d
|
|||
|
194acacab4
|
|||
|
6cf4ef3f93
|
|||
|
104b828d47
|
|||
|
318598b8cf
|
|||
|
5616778421
|
|||
|
bec32b4c0e
|
|||
|
2832598881
|
|||
|
079834ca72
|
|||
|
d44010f7a3
|
|||
|
b02cdb14b3
|
|||
|
be8342fa18
|
|||
|
f96fd4ac14
|
|||
|
b96d1a62ec
|
|||
|
ab85de0a0f
|
|||
|
64f30a04c0
|
|||
|
303864e37b
|
|||
|
b1c7cb6741
|
|||
|
f8e846ab0c
|
|||
| c6bb82894e | |||
| 1fc6ab278b | |||
|
f2c128094e
|
|||
|
f34ad12b88
|
|||
| c309fbb743 | |||
|
6765a6e131
|
|||
|
a37054efe1
|
|||
|
f5692e659c
|
|||
|
ef86a70ca5
|
|||
|
5009e83f62
|
|||
|
1f8cb4411e
|
|||
|
05a8adef80
|
|||
| 4e772cc9e1 | |||
| a10a429aa9 | |||
|
01b9b576eb
|
|||
|
893c811802
|
|||
|
3fed3b425e
|
|||
|
d89853b4d2
|
|||
|
d94ab958d5
|
|||
|
1277750716
|
|||
|
247a46d430
|
|||
|
703658335c
|
|||
|
b2ed0fcb41
|
|||
|
3dfee251ec
|
|||
|
8e0183d8af
|
@@ -0,0 +1,15 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: [SoPat712]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: joshpatra
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
polar: # Replace with a single Polar username
|
||||||
|
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||||
|
thanks_dev: # Replace with a single thanks.dev username
|
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
name: Build & Release Firefox Addon
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
WEB_EXT_IGNORE_FILES: scripts/**
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install deps
|
||||||
|
run: npm install -g web-ext
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: web-ext lint
|
||||||
|
|
||||||
|
# Beta tag (v*-beta) → Sign as unlisted on AMO, attach signed XPI to GitHub Prerelease
|
||||||
|
# Firefox blocks all unsigned XPIs, even for self-hosted installs — unlisted signing is required
|
||||||
|
- name: Sign XPI via AMO (unlisted, beta)
|
||||||
|
if: contains(github.ref_name, '-beta')
|
||||||
|
run: |
|
||||||
|
web-ext sign \
|
||||||
|
--api-key ${{ secrets.FIREFOX_API_KEY }} \
|
||||||
|
--api-secret ${{ secrets.FIREFOX_API_SECRET }} \
|
||||||
|
--source-dir . \
|
||||||
|
--artifacts-dir web-ext-artifacts \
|
||||||
|
--channel unlisted
|
||||||
|
|
||||||
|
- name: Get signed XPI path (beta)
|
||||||
|
if: contains(github.ref_name, '-beta')
|
||||||
|
id: xpi
|
||||||
|
run: |
|
||||||
|
FILE=$(ls web-ext-artifacts/*.xpi | head -n 1)
|
||||||
|
XPI="web-ext-artifacts/speeder-${{ github.ref_name }}.xpi"
|
||||||
|
mv "$FILE" "$XPI"
|
||||||
|
echo "file=$XPI" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create GitHub Prerelease (beta)
|
||||||
|
if: contains(github.ref_name, '-beta')
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref_name }}
|
||||||
|
name: ${{ github.ref_name }}
|
||||||
|
files: ${{ steps.xpi.outputs.file }}
|
||||||
|
prerelease: true
|
||||||
|
body: |
|
||||||
|
Beta build — signed for self-hosted manual installation.
|
||||||
|
|
||||||
|
### Installation Instructions
|
||||||
|
1. Click the `.xpi` file below
|
||||||
|
2. Click "Continue to Installation"
|
||||||
|
3. Click "Add"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Stable tag (v* without -beta) → Sign & submit to public AMO listing
|
||||||
|
- name: Sign & Submit to AMO (stable)
|
||||||
|
if:
|
||||||
|
startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name,
|
||||||
|
'-beta')
|
||||||
|
run: |
|
||||||
|
web-ext sign \
|
||||||
|
--api-key ${{ secrets.FIREFOX_API_KEY }} \
|
||||||
|
--api-secret ${{ secrets.FIREFOX_API_SECRET }} \
|
||||||
|
--source-dir . \
|
||||||
|
--artifacts-dir web-ext-artifacts \
|
||||||
|
--channel listed
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode/
|
||||||
local
|
local
|
||||||
|
|
||||||
# IntelliJ IDEA
|
# IntelliJ IDEA
|
||||||
|
*.xpi
|
||||||
.idea/
|
.idea/
|
||||||
node_modules
|
node_modules
|
||||||
|
__pycache__/
|
||||||
|
temp/
|
||||||
|
|||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"kiroAgent.configureMCP": "Disabled"
|
||||||
|
}
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[](https://addons.mozilla.org/en-US/firefox/addon/video-speed-controller-v1/)
|
# Available for Firefox
|
||||||
|
[](https://addons.mozilla.org//firefox/addon/speeder/)
|
||||||
|
|
||||||
|
|
||||||
# The science of accelerated playback
|
# The science of accelerated playback
|
||||||
@@ -7,19 +7,19 @@
|
|||||||
**TL;DR: faster playback translates to better engagement and retention.**
|
**TL;DR: faster playback translates to better engagement and retention.**
|
||||||
|
|
||||||
Average adult reads prose text at
|
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)
|
[250 to 300 words per minute](https://web.archive.org/web/20220325065025/https://www.domtar.com/en/resources/paper-advocacy/paperbecause)
|
||||||
(wpm). By contrast, the average rate of speech for English speakers is ~150 wpm,
|
(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
|
with slide presentations often closer to 100 wpm. As a result, when given the
|
||||||
choice, many viewers
|
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)
|
[speed up video playback to ~1.3\~1.5 its recorded rate](https://research.microsoft.com/en-us/um/redmond/groups/coet/compression/chi99/paper.pdf)
|
||||||
to compensate for the difference.
|
to compensate for the difference.
|
||||||
|
|
||||||
Many viewers report that
|
Many viewers report that
|
||||||
[accelerated viewing keeps their attention longer](http://www.enounce.com/docs/BYUPaper020319.pdf):
|
[accelerated viewing keeps their attention longer](https://www.enounce.com/docs/BYUPaper020319.pdf):
|
||||||
faster delivery keeps the viewer more engaged with the content. In fact, with a
|
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
|
little training many end up watching videos at 2x+ the recorded speed. Some
|
||||||
studies report that after being exposed to accelerated playback,
|
studies report that after being exposed to accelerated playback,
|
||||||
[listeners become uncomfortable](http://alumni.media.mit.edu/~barons/html/avios92.html#beasleyalteredspeech)
|
[listeners become uncomfortable](https://web.archive.org/web/20230912173120/http://alumni.media.mit.edu/~barons/html/avios92.html)
|
||||||
if they are forced to return to normal rate of presentation.
|
if they are forced to return to normal rate of presentation.
|
||||||
|
|
||||||
## Faster HTML5 Video
|
## Faster HTML5 Video
|
||||||
@@ -36,7 +36,7 @@ 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*
|
#### *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
|
\*\* 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
|
HTML5 video ([example](https://www.youtube.com/watch?v=E9FxNzv1Tr8)), and you'll
|
||||||
see a speed indicator in top left corner. Hover over the indicator to reveal the
|
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,
|
controls to accelerate, slowdown, and quickly rewind or advance the video. Or,
|
||||||
even better, simply use your keyboard:
|
even better, simply use your keyboard:
|
||||||
@@ -74,14 +74,12 @@ 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.
|
most sites will fallback to HTML5 if they detect that Flash is not available.
|
||||||
You can try manually disabling Flash from the browser.
|
You can try manually disabling Flash from the browser.
|
||||||
|
|
||||||
**What is this fork of `igrigorik/videospeed` all about?** This fork of the
|
**What is this fork all about?** This is a fork of
|
||||||
[`igrigorik/videospeed`](https://github.com/igrigorik/videospeed) repository
|
[CodeBicycle's Video Speed Controller extension for Firefox](https://github.com/codebicycle/videospeed)
|
||||||
is a port of [`igrigorik`](https://github.com/igrigorik)'s videospeed Chrome
|
which is a fork of [Igrigorik's Video Speed Controller extension for Chromium](https://github.com/igrigorik/videospeed).
|
||||||
add-on for Firefox. This fork modifies the Chrome add-on code so that it works
|
|
||||||
in Firefox. This repo is the code behind the [Firefox Extension](https://addons.mozilla.org/en-US/firefox/addon/video-speed-controller-v1/)
|
The goal of this fork is fix bugs in the upstream code as well as add new features.
|
||||||
whereas the [`igrigorik/videospeed`](https://github.com/igrigorik/videospeed)
|
|
||||||
repository contains the code behind the [Chrome Extension](https://chrome.google.com/webstore/detail/video-speed-controller/nffaoalbilbmmfgbnbgppjihopabppdk).
|
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
(MIT License) - Copyright (c) 2025 Josh Patra
|
(GPLv3) - Copyright (c) 2025 Josh Patra
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
chrome.runtime.onMessage.addListener(function (request) {
|
||||||
|
if (request.action === "openOptions") {
|
||||||
|
chrome.tabs.create({ url: chrome.runtime.getURL("options.html") });
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
import glob
|
||||||
|
import fnmatch
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
SCRIPT_NAME = os.path.basename(__file__)
|
||||||
|
TARGET_FILE = "manifest.json"
|
||||||
|
DEFAULT_EXCLUDE_FILES = {".DS_Store"}
|
||||||
|
DEFAULT_EXCLUDE_DIRS = {"__pycache__", "temp"}
|
||||||
|
DEFAULT_EXCLUDE_PATTERNS = {"._*", "*.pyc"}
|
||||||
|
|
||||||
|
|
||||||
|
def should_exclude(rel_path, exclude_files, exclude_dirs):
|
||||||
|
rel_path = os.path.normpath(rel_path)
|
||||||
|
path_parts = rel_path.split(os.sep)
|
||||||
|
file_name = path_parts[-1]
|
||||||
|
|
||||||
|
if file_name in DEFAULT_EXCLUDE_FILES or rel_path in DEFAULT_EXCLUDE_FILES:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if any(part in DEFAULT_EXCLUDE_DIRS for part in path_parts):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if file_name in exclude_files or rel_path in exclude_files:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if any(part in exclude_dirs for part in path_parts):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if any(fnmatch.fnmatch(file_name, pattern) for pattern in DEFAULT_EXCLUDE_PATTERNS):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def zip_folder(output_name, folder, exclude_files, exclude_dirs):
|
||||||
|
with zipfile.ZipFile(output_name, "w", zipfile.ZIP_DEFLATED) as zipf:
|
||||||
|
for root, dirs, files in os.walk(folder):
|
||||||
|
dirs[:] = [
|
||||||
|
d
|
||||||
|
for d in dirs
|
||||||
|
if not should_exclude(
|
||||||
|
os.path.relpath(os.path.join(root, d), folder),
|
||||||
|
exclude_files,
|
||||||
|
exclude_dirs,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
for file in files:
|
||||||
|
rel_path = os.path.relpath(os.path.join(root, file), folder)
|
||||||
|
if should_exclude(rel_path, exclude_files, exclude_dirs):
|
||||||
|
continue
|
||||||
|
zipf.write(os.path.join(root, file), arcname=rel_path)
|
||||||
|
|
||||||
|
|
||||||
|
def update_version_line(file_path, new_version):
|
||||||
|
with open(file_path, "r", encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
|
||||||
|
updated = False
|
||||||
|
for i, line in enumerate(lines):
|
||||||
|
match = re.match(r'\s*"version":\s*"([^"]+)"', line)
|
||||||
|
if match:
|
||||||
|
old_version = match.group(1)
|
||||||
|
lines[i] = re.sub(
|
||||||
|
r'"version":\s*".+?"', f'"version": "{new_version}"', line
|
||||||
|
)
|
||||||
|
updated = True
|
||||||
|
print(
|
||||||
|
f"🛠️ Changed version in {file_path} from {old_version} ➜ {new_version}"
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
|
if updated:
|
||||||
|
with open(file_path, "w", encoding="utf-8") as f:
|
||||||
|
f.writelines(lines)
|
||||||
|
else:
|
||||||
|
print(f"⚠️ No version line found in {file_path}.")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Step 0: Remove all existing .xpi files upfront
|
||||||
|
xpi_files = glob.glob("*.xpi")
|
||||||
|
for f in xpi_files:
|
||||||
|
try:
|
||||||
|
os.remove(f)
|
||||||
|
print(f"🗑️ Removed existing archive: {f}")
|
||||||
|
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
|
||||||
|
|
||||||
|
github_version = f"{base_version}.0"
|
||||||
|
|
||||||
|
# Step 1: Update manifest.json on disk to base_version (for Firefox)
|
||||||
|
if os.path.exists(manifest_path):
|
||||||
|
update_version_line(manifest_path, base_version)
|
||||||
|
else:
|
||||||
|
print(f"❌ {TARGET_FILE} not found. Aborting.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Step 2: Create videospeed-firefox.xpi (exclude script, .git, AND videospeed-firefox.xpi itself)
|
||||||
|
exclude_files = [SCRIPT_NAME, "videospeed-firefox.xpi"]
|
||||||
|
exclude_dirs = [".git"]
|
||||||
|
zip_folder("videospeed-firefox.xpi", current_dir, exclude_files, exclude_dirs)
|
||||||
|
print("✅ Created videospeed-firefox.xpi")
|
||||||
|
|
||||||
|
# Step 3: Re-scan for .xpi files after Firefox archive creation, exclude them for GitHub zip
|
||||||
|
current_xpi_files = set(glob.glob("*.xpi"))
|
||||||
|
exclude_temp_files = current_xpi_files.union({SCRIPT_NAME})
|
||||||
|
exclude_temp_dirs = set(exclude_dirs)
|
||||||
|
|
||||||
|
# Step 4: Create videospeed-github.xpi from temp folder with version bumped to .0
|
||||||
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
for item in os.listdir(current_dir):
|
||||||
|
if should_exclude(item, exclude_temp_files, exclude_temp_dirs):
|
||||||
|
continue
|
||||||
|
src = os.path.join(current_dir, item)
|
||||||
|
dst = os.path.join(temp_dir, item)
|
||||||
|
if os.path.isdir(src):
|
||||||
|
shutil.copytree(src, dst)
|
||||||
|
else:
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
|
temp_manifest = os.path.join(temp_dir, TARGET_FILE)
|
||||||
|
if os.path.exists(temp_manifest):
|
||||||
|
update_version_line(temp_manifest, github_version)
|
||||||
|
else:
|
||||||
|
print(f"⚠️ {TARGET_FILE} not found in temp folder.")
|
||||||
|
|
||||||
|
zip_folder(
|
||||||
|
"videospeed-github.xpi", temp_dir, exclude_files=[], exclude_dirs=[]
|
||||||
|
)
|
||||||
|
print("✅ Created videospeed-github.xpi")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/* Runs via chrome.tabs.executeScript(allFrames) in the same isolated world as inject.js */
|
||||||
|
(function () {
|
||||||
|
try {
|
||||||
|
if (typeof getPrimaryVideoElement !== "function") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var v = getPrimaryVideoElement();
|
||||||
|
if (!v) return null;
|
||||||
|
return {
|
||||||
|
speed: v.playbackRate,
|
||||||
|
preferred: !v.paused
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})();
|
||||||
+156
@@ -0,0 +1,156 @@
|
|||||||
|
// Import/Export functionality for Video Speed Controller settings
|
||||||
|
|
||||||
|
function generateBackupFilename() {
|
||||||
|
const now = new Date();
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(now.getDate()).padStart(2, "0");
|
||||||
|
const hours = String(now.getHours()).padStart(2, "0");
|
||||||
|
const minutes = String(now.getMinutes()).padStart(2, "0");
|
||||||
|
const seconds = String(now.getSeconds()).padStart(2, "0");
|
||||||
|
return `speeder-backup_${year}-${month}-${day}_${hours}.${minutes}.${seconds}.json`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportSettings() {
|
||||||
|
chrome.storage.sync.get(null, function (storage) {
|
||||||
|
chrome.storage.local.get(null, function (localStorage) {
|
||||||
|
const backup = {
|
||||||
|
version: "1.1",
|
||||||
|
exportDate: new Date().toISOString(),
|
||||||
|
settings: storage,
|
||||||
|
localSettings: localStorage || {}
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataStr = JSON.stringify(backup, null, 2);
|
||||||
|
const blob = new Blob([dataStr], { type: "application/json" });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = url;
|
||||||
|
link.download = generateBackupFilename();
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
|
||||||
|
showStatus("Settings exported successfully");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function importSettings() {
|
||||||
|
const input = document.createElement("input");
|
||||||
|
input.type = "file";
|
||||||
|
input.accept = ".json";
|
||||||
|
|
||||||
|
input.onchange = function (event) {
|
||||||
|
const file = event.target.files[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = function (e) {
|
||||||
|
try {
|
||||||
|
const backup = JSON.parse(e.target.result);
|
||||||
|
let settingsToImport = null;
|
||||||
|
|
||||||
|
// Detect backup format: check for 'settings' wrapper or raw storage keys
|
||||||
|
if (backup.settings && typeof backup.settings === "object") {
|
||||||
|
settingsToImport = backup.settings;
|
||||||
|
} else if (typeof backup === "object" && (backup.keyBindings || backup.rememberSpeed !== undefined)) {
|
||||||
|
settingsToImport = backup; // Raw storage object
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!settingsToImport) {
|
||||||
|
showStatus("Error: Invalid backup file format", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var localToImport =
|
||||||
|
backup.localSettings && typeof backup.localSettings === "object"
|
||||||
|
? backup.localSettings
|
||||||
|
: null;
|
||||||
|
|
||||||
|
function afterLocalImport() {
|
||||||
|
chrome.storage.sync.clear(function () {
|
||||||
|
chrome.storage.sync.set(settingsToImport, function () {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
showStatus(
|
||||||
|
"Error: Failed to save imported settings - " +
|
||||||
|
chrome.runtime.lastError.message,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showStatus("Settings imported successfully. Reloading...");
|
||||||
|
setTimeout(function () {
|
||||||
|
if (typeof restore_options === "function") {
|
||||||
|
restore_options();
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localToImport && Object.keys(localToImport).length > 0) {
|
||||||
|
chrome.storage.local.set(localToImport, function () {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
showStatus(
|
||||||
|
"Error: Failed to save local extension data - " +
|
||||||
|
chrome.runtime.lastError.message,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
afterLocalImport();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
afterLocalImport();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
showStatus("Error: Failed to parse backup file - " + err.message, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.onerror = function () {
|
||||||
|
showStatus("Error: Failed to read file", true);
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsText(file);
|
||||||
|
};
|
||||||
|
|
||||||
|
input.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showStatus(message, isError = false) {
|
||||||
|
const status = document.getElementById("status");
|
||||||
|
if (status) {
|
||||||
|
status.textContent = message;
|
||||||
|
status.style.color = isError ? "#d32f2f" : "";
|
||||||
|
setTimeout(function () {
|
||||||
|
status.textContent = "";
|
||||||
|
status.style.color = "";
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize import/export buttons when DOM is ready
|
||||||
|
if (document.readyState === "loading") {
|
||||||
|
document.addEventListener("DOMContentLoaded", initImportExport);
|
||||||
|
} else {
|
||||||
|
initImportExport();
|
||||||
|
}
|
||||||
|
|
||||||
|
function initImportExport() {
|
||||||
|
const exportBtn = document.getElementById("exportSettings");
|
||||||
|
const importBtn = document.getElementById("importSettings");
|
||||||
|
|
||||||
|
if (exportBtn) {
|
||||||
|
exportBtn.addEventListener("click", exportSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (importBtn) {
|
||||||
|
importBtn.addEventListener("click", importSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
-66
@@ -1,83 +1,48 @@
|
|||||||
|
/* Base styles for the controller wrapper (the shadow host) */
|
||||||
|
.vsc-controller {
|
||||||
|
position: absolute !important;
|
||||||
|
top: 0 !important;
|
||||||
|
left: 0 !important;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
pointer-events: none !important;
|
||||||
|
z-index: 2147483646 !important;
|
||||||
|
white-space: normal;
|
||||||
|
overflow: visible !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use minimal z-index for non-YouTube sites to avoid overlapping modals */
|
||||||
|
.vsc-controller.vsc-non-youtube {
|
||||||
|
z-index: 1 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.vsc-nosource {
|
.vsc-nosource {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
.vsc-hidden {
|
.vsc-hidden {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
.vsc-manual {
|
|
||||||
visibility: visible !important;
|
|
||||||
opacity: 1 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vsc-controller {
|
/* YouTube auto-hide feature: fade controller with YouTube's controls */
|
||||||
/* In case of pages using `white-space: pre-line` (eg Discord), don't render vsc's whitespace */
|
/* When the wrapper has ytp-autohide class, hide it (unless vsc-hidden overrides) */
|
||||||
white-space: normal;
|
.vsc-controller.ytp-autohide:not(.vsc-hidden),
|
||||||
}
|
.vsc-controller.vsc-idle-hidden:not(.vsc-hidden) {
|
||||||
|
|
||||||
/* Origin specific overrides */
|
|
||||||
/* YouTube player */
|
|
||||||
.ytp-hide-info-bar .vsc-controller {
|
|
||||||
position: relative;
|
|
||||||
top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ytp-autohide .vsc-controller {
|
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ytp-autohide .vcs-show {
|
/* Show it temporarily when it has vsc-show class */
|
||||||
visibility: visible;
|
.vsc-controller.ytp-autohide.vsc-show:not(.vsc-hidden),
|
||||||
opacity: 1;
|
.vsc-controller.vsc-idle-hidden.vsc-show:not(.vsc-hidden),
|
||||||
|
.vsc-controller.vsc-forced-show:not(.vsc-hidden) {
|
||||||
|
visibility: visible !important;
|
||||||
|
opacity: 1 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* YouTube embedded player */
|
/* Original overrides removed to avoid interference with the new anchoring system.
|
||||||
/* e.g. https://www.igvita.com/2012/09/12/web-fonts-performance-making-pretty-fast/ */
|
The .vsc-controller wrapper now fills the player container exactly,
|
||||||
.html5-video-player:not(.ytp-hide-info-bar) .vsc-controller {
|
allowing #controller (inside shadow root) to anchor correctly to all 8 positions. */
|
||||||
position: relative;
|
|
||||||
top: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Facebook player */
|
|
||||||
#facebook .vsc-controller {
|
|
||||||
position: relative;
|
|
||||||
top: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Google Photos player */
|
|
||||||
/* Inline preview doesn't have any additional hooks, relying on Aria label */
|
|
||||||
a[aria-label^="Video"] .vsc-controller {
|
|
||||||
position: relative;
|
|
||||||
top: 35px;
|
|
||||||
}
|
|
||||||
/* Google Photos full-screen view */
|
|
||||||
#player .house-brand .vsc-controller {
|
|
||||||
position: relative;
|
|
||||||
top: 50px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Netflix player */
|
|
||||||
#netflix-player:not(.player-cinema-mode) .vsc-controller {
|
|
||||||
position: relative;
|
|
||||||
top: 85px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* shift controller on vine.co */
|
|
||||||
/* e.g. https://vine.co/v/OrJj39YlL57 */
|
|
||||||
.video-container .vine-video-container .vsc-controller {
|
|
||||||
margin-left: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* shift YT 3D controller down */
|
|
||||||
/* e.g. https://www.youtube.com/watch?v=erftYPflJzQ */
|
|
||||||
.ytp-webgl-spherical-control {
|
|
||||||
top: 60px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ytp-fullscreen .ytp-webgl-spherical-control {
|
|
||||||
top: 100px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* disable Vimeo video overlay */
|
/* disable Vimeo video overlay */
|
||||||
div.video-wrapper + div.target {
|
div.video-wrapper + div.target {
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
var regStrip = /^[\r\t\f\v ]+|[\r\t\f\v ]+$/gm;
|
var isUserSeek = false; // Track if seek was user-initiated
|
||||||
|
var lastToggleSpeed = {}; // Store last toggle speeds per video
|
||||||
|
|
||||||
|
function getPrimaryVideoElement() {
|
||||||
|
if (!tc.mediaElements || tc.mediaElements.length === 0) return null;
|
||||||
|
for (var i = 0; i < tc.mediaElements.length; i++) {
|
||||||
|
var el = tc.mediaElements[i];
|
||||||
|
if (el && !el.paused) return el;
|
||||||
|
}
|
||||||
|
return tc.mediaElements[0];
|
||||||
|
}
|
||||||
|
|
||||||
var tc = {
|
var tc = {
|
||||||
settings: {
|
settings: {
|
||||||
@@ -10,25 +20,1160 @@ var tc = {
|
|||||||
forceLastSavedSpeed: false,
|
forceLastSavedSpeed: false,
|
||||||
audioBoolean: false,
|
audioBoolean: false,
|
||||||
startHidden: false,
|
startHidden: false,
|
||||||
|
hideWithYouTubeControls: false,
|
||||||
|
hideWithControls: false,
|
||||||
|
hideWithControlsTimer: 2.0,
|
||||||
|
controllerLocation: "top-left",
|
||||||
controllerOpacity: 0.3,
|
controllerOpacity: 0.3,
|
||||||
|
controllerMarginTop: 0,
|
||||||
|
controllerMarginRight: 0,
|
||||||
|
controllerMarginBottom: 65,
|
||||||
|
controllerMarginLeft: 0,
|
||||||
keyBindings: [],
|
keyBindings: [],
|
||||||
blacklist: `\
|
siteRules: [],
|
||||||
www.instagram.com
|
controllerButtons: ["rewind", "slower", "faster", "advance", "display"],
|
||||||
twitter.com
|
defaultLogLevel: 3,
|
||||||
vine.co
|
logLevel: 3,
|
||||||
imgur.com
|
enableSubtitleNudge: true, // Enabled by default, but only activates on YouTube
|
||||||
teams.microsoft.com
|
subtitleNudgeInterval: 50, // Default 50ms balances subtitle tracking with CPU cost
|
||||||
`.replace(regStrip, ""),
|
subtitleNudgeAmount: 0.001,
|
||||||
defaultLogLevel: 4,
|
customButtonIcons: {}
|
||||||
logLevel: 5, // Set to 5 to see your debug logs
|
|
||||||
enableSubtitleNudge: true,
|
|
||||||
subtitleNudgeInterval: 25,
|
|
||||||
subtitleNudgeAmount: 0.001
|
|
||||||
},
|
},
|
||||||
mediaElements: [],
|
mediaElements: [],
|
||||||
isNudging: false
|
isNudging: false,
|
||||||
|
pendingLastSpeedSave: null,
|
||||||
|
pendingLastSpeedValue: null,
|
||||||
|
persistedLastSpeed: 1.0,
|
||||||
|
activeSiteRule: null,
|
||||||
|
siteRuleBase: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var MIN_SPEED = 0.0625;
|
||||||
|
var MAX_SPEED = 16;
|
||||||
|
var YT_NATIVE_MIN = 0.25;
|
||||||
|
var YT_NATIVE_MAX = 2.0;
|
||||||
|
var YT_NATIVE_STEP = 0.05;
|
||||||
|
var vscObservedRoots = new WeakSet();
|
||||||
|
var requestIdle =
|
||||||
|
typeof window.requestIdleCallback === "function"
|
||||||
|
? window.requestIdleCallback.bind(window)
|
||||||
|
: function (callback, options) {
|
||||||
|
return setTimeout(callback, (options && options.timeout) || 1);
|
||||||
|
};
|
||||||
|
var controllerLocations = [
|
||||||
|
"top-left",
|
||||||
|
"top-center",
|
||||||
|
"top-right",
|
||||||
|
"middle-right",
|
||||||
|
"bottom-right",
|
||||||
|
"bottom-center",
|
||||||
|
"bottom-left",
|
||||||
|
"middle-left"
|
||||||
|
];
|
||||||
|
var defaultControllerLocation = controllerLocations[0];
|
||||||
|
var controllerLocationStyles = {
|
||||||
|
"top-left": {
|
||||||
|
top: "10px",
|
||||||
|
left: "15px",
|
||||||
|
transform: "translate(0, 0)"
|
||||||
|
},
|
||||||
|
"top-center": {
|
||||||
|
top: "10px",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%, 0)"
|
||||||
|
},
|
||||||
|
"top-right": {
|
||||||
|
top: "10px",
|
||||||
|
left: "calc(100% - 10px)",
|
||||||
|
transform: "translate(-100%, 0)"
|
||||||
|
},
|
||||||
|
"middle-right": {
|
||||||
|
top: "50%",
|
||||||
|
left: "calc(100% - 10px)",
|
||||||
|
transform: "translate(-100%, -50%)"
|
||||||
|
},
|
||||||
|
"bottom-right": {
|
||||||
|
top: "calc(100% - 0px)",
|
||||||
|
left: "calc(100% - 10px)",
|
||||||
|
transform: "translate(-100%, -100%)"
|
||||||
|
},
|
||||||
|
"bottom-center": {
|
||||||
|
top: "calc(100% - 0px)",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%, -100%)"
|
||||||
|
},
|
||||||
|
"bottom-left": {
|
||||||
|
top: "calc(100% - 0px)",
|
||||||
|
left: "15px",
|
||||||
|
transform: "translate(0, -100%)"
|
||||||
|
},
|
||||||
|
"middle-left": {
|
||||||
|
top: "50%",
|
||||||
|
left: "15px",
|
||||||
|
transform: "translate(0, -50%)"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* `label` fallback only when ui-icons has no path for the action. */
|
||||||
|
var controllerButtonDefs = {
|
||||||
|
rewind: { label: "", className: "rw" },
|
||||||
|
slower: { label: "", className: "" },
|
||||||
|
faster: { label: "", className: "" },
|
||||||
|
advance: { label: "", className: "rw" },
|
||||||
|
display: { label: "", className: "hideButton" },
|
||||||
|
reset: { label: "\u21BB", className: "" },
|
||||||
|
fast: { label: "", className: "" },
|
||||||
|
settings: { label: "", className: "" },
|
||||||
|
pause: { label: "", className: "" },
|
||||||
|
muted: { label: "", className: "" },
|
||||||
|
mark: { label: "", className: "" },
|
||||||
|
jump: { label: "", className: "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
var keyCodeToEventKey = {
|
||||||
|
32: " ",
|
||||||
|
37: "ArrowLeft",
|
||||||
|
38: "ArrowUp",
|
||||||
|
39: "ArrowRight",
|
||||||
|
40: "ArrowDown",
|
||||||
|
96: "0",
|
||||||
|
97: "1",
|
||||||
|
98: "2",
|
||||||
|
99: "3",
|
||||||
|
100: "4",
|
||||||
|
101: "5",
|
||||||
|
102: "6",
|
||||||
|
103: "7",
|
||||||
|
104: "8",
|
||||||
|
105: "9",
|
||||||
|
106: "*",
|
||||||
|
107: "+",
|
||||||
|
109: "-",
|
||||||
|
110: ".",
|
||||||
|
111: "/",
|
||||||
|
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 createDefaultBinding(action, key, keyCode, value) {
|
||||||
|
return {
|
||||||
|
action: action,
|
||||||
|
key: key,
|
||||||
|
keyCode: keyCode,
|
||||||
|
value: value,
|
||||||
|
force: false,
|
||||||
|
predefined: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultKeyBindings(storage) {
|
||||||
|
return [
|
||||||
|
createDefaultBinding(
|
||||||
|
"slower",
|
||||||
|
"S",
|
||||||
|
Number(storage.slowerKeyCode) || 83,
|
||||||
|
Number(storage.speedStep) || 0.1
|
||||||
|
),
|
||||||
|
createDefaultBinding(
|
||||||
|
"faster",
|
||||||
|
"D",
|
||||||
|
Number(storage.fasterKeyCode) || 68,
|
||||||
|
Number(storage.speedStep) || 0.1
|
||||||
|
),
|
||||||
|
createDefaultBinding(
|
||||||
|
"rewind",
|
||||||
|
"Z",
|
||||||
|
Number(storage.rewindKeyCode) || 90,
|
||||||
|
Number(storage.rewindTime) || 10
|
||||||
|
),
|
||||||
|
createDefaultBinding(
|
||||||
|
"advance",
|
||||||
|
"X",
|
||||||
|
Number(storage.advanceKeyCode) || 88,
|
||||||
|
Number(storage.advanceTime) || 10
|
||||||
|
),
|
||||||
|
createDefaultBinding(
|
||||||
|
"reset",
|
||||||
|
"R",
|
||||||
|
Number(storage.resetKeyCode) || 82,
|
||||||
|
1.0
|
||||||
|
),
|
||||||
|
createDefaultBinding(
|
||||||
|
"fast",
|
||||||
|
"G",
|
||||||
|
Number(storage.fastKeyCode) || 71,
|
||||||
|
Number(storage.fastSpeed) || 1.8
|
||||||
|
),
|
||||||
|
createDefaultBinding(
|
||||||
|
"move",
|
||||||
|
"P",
|
||||||
|
80,
|
||||||
|
0
|
||||||
|
),
|
||||||
|
createDefaultBinding(
|
||||||
|
"toggleSubtitleNudge",
|
||||||
|
"N",
|
||||||
|
78,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureDefaultKeyBinding(action, key, keyCode, value) {
|
||||||
|
if (tc.settings.keyBindings.some((binding) => binding.action === action)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tc.settings.keyBindings.push(
|
||||||
|
createDefaultBinding(action, key, keyCode, value)
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLegacyKeyCode(binding) {
|
||||||
|
if (!binding) return null;
|
||||||
|
if (Number.isInteger(binding.keyCode)) return binding.keyCode;
|
||||||
|
if (typeof binding.key === "number" && Number.isInteger(binding.key)) {
|
||||||
|
return binding.key;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeControllerLocation(location) {
|
||||||
|
if (controllerLocations.includes(location)) return location;
|
||||||
|
return defaultControllerLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
var CONTROLLER_MARGIN_MAX_PX = 200;
|
||||||
|
|
||||||
|
function normalizeControllerMarginPx(value, fallback) {
|
||||||
|
var n = Number(value);
|
||||||
|
if (!Number.isFinite(n)) return fallback;
|
||||||
|
return Math.min(
|
||||||
|
CONTROLLER_MARGIN_MAX_PX,
|
||||||
|
Math.max(0, Math.round(n))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyControllerMargins(controller) {
|
||||||
|
if (!controller) return;
|
||||||
|
var d = tc.settings;
|
||||||
|
var loc = controller.dataset.location;
|
||||||
|
var manual = controller.dataset.positionMode === "manual";
|
||||||
|
var isTopAnchored =
|
||||||
|
!manual &&
|
||||||
|
(loc === "top-left" ||
|
||||||
|
loc === "top-center" ||
|
||||||
|
loc === "top-right");
|
||||||
|
var isBottomAnchored =
|
||||||
|
!manual &&
|
||||||
|
(loc === "bottom-right" ||
|
||||||
|
loc === "bottom-center" ||
|
||||||
|
loc === "bottom-left");
|
||||||
|
var isMiddleRow =
|
||||||
|
!manual && (loc === "middle-left" || loc === "middle-right");
|
||||||
|
var mt = normalizeControllerMarginPx(d.controllerMarginTop, 0);
|
||||||
|
var mb = normalizeControllerMarginPx(d.controllerMarginBottom, 65);
|
||||||
|
if (isTopAnchored || isBottomAnchored || isMiddleRow) {
|
||||||
|
mt = 0;
|
||||||
|
mb = 0;
|
||||||
|
}
|
||||||
|
controller.style.marginTop = mt + "px";
|
||||||
|
var ml = normalizeControllerMarginPx(d.controllerMarginLeft, 0);
|
||||||
|
var mr = normalizeControllerMarginPx(d.controllerMarginRight, 0);
|
||||||
|
if (!manual) {
|
||||||
|
ml = 0;
|
||||||
|
mr = 0;
|
||||||
|
}
|
||||||
|
controller.style.marginRight = mr + "px";
|
||||||
|
controller.style.marginBottom = mb + "px";
|
||||||
|
controller.style.marginLeft = ml + "px";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNextControllerLocation(location) {
|
||||||
|
var normalizedLocation = normalizeControllerLocation(location);
|
||||||
|
var currentIndex = controllerLocations.indexOf(normalizedLocation);
|
||||||
|
return controllerLocations[(currentIndex + 1) % controllerLocations.length];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getControllerElement(videoOrController) {
|
||||||
|
if (!videoOrController) return null;
|
||||||
|
|
||||||
|
if (
|
||||||
|
videoOrController.shadowRoot &&
|
||||||
|
typeof videoOrController.shadowRoot.querySelector === "function"
|
||||||
|
) {
|
||||||
|
return videoOrController.shadowRoot.querySelector("#controller");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
videoOrController.div &&
|
||||||
|
videoOrController.div.shadowRoot &&
|
||||||
|
typeof videoOrController.div.shadowRoot.querySelector === "function"
|
||||||
|
) {
|
||||||
|
return videoOrController.div.shadowRoot.querySelector("#controller");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyControllerLocationToElement(controller, location) {
|
||||||
|
if (!controller) return defaultControllerLocation;
|
||||||
|
var normalizedLocation = normalizeControllerLocation(location);
|
||||||
|
var styles = controllerLocationStyles[normalizedLocation];
|
||||||
|
|
||||||
|
controller.dataset.location = normalizedLocation;
|
||||||
|
controller.dataset.positionMode = "anchored";
|
||||||
|
|
||||||
|
var top = styles.top;
|
||||||
|
if (
|
||||||
|
normalizedLocation === "top-left" ||
|
||||||
|
normalizedLocation === "top-center" ||
|
||||||
|
normalizedLocation === "top-right"
|
||||||
|
) {
|
||||||
|
var insetTop = normalizeControllerMarginPx(
|
||||||
|
tc.settings.controllerMarginTop,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
top = "calc(10px + " + insetTop + "px)";
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
normalizedLocation === "bottom-right" ||
|
||||||
|
normalizedLocation === "bottom-center" ||
|
||||||
|
normalizedLocation === "bottom-left"
|
||||||
|
) {
|
||||||
|
var lift = normalizeControllerMarginPx(
|
||||||
|
tc.settings.controllerMarginBottom,
|
||||||
|
65
|
||||||
|
);
|
||||||
|
top = "calc(100% - " + lift + "px)";
|
||||||
|
}
|
||||||
|
// If in fullscreen, move the controller down to avoid overlapping video titles
|
||||||
|
if (
|
||||||
|
document.fullscreenElement ||
|
||||||
|
document.webkitFullscreenElement ||
|
||||||
|
document.mozFullScreenElement ||
|
||||||
|
document.msFullscreenElement
|
||||||
|
) {
|
||||||
|
if (normalizedLocation.startsWith("top-")) {
|
||||||
|
var insetTopFs = normalizeControllerMarginPx(
|
||||||
|
tc.settings.controllerMarginTop,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
top = "calc(63px + " + insetTopFs + "px)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.style.top = top;
|
||||||
|
|
||||||
|
var left = styles.left;
|
||||||
|
switch (normalizedLocation) {
|
||||||
|
case "top-left":
|
||||||
|
case "middle-left":
|
||||||
|
case "bottom-left":
|
||||||
|
left = "15px";
|
||||||
|
break;
|
||||||
|
case "top-right":
|
||||||
|
case "middle-right":
|
||||||
|
case "bottom-right":
|
||||||
|
left = "calc(100% - 10px)";
|
||||||
|
break;
|
||||||
|
case "top-center":
|
||||||
|
case "bottom-center":
|
||||||
|
left = "50%";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
controller.style.left = left;
|
||||||
|
controller.style.transform = styles.transform;
|
||||||
|
|
||||||
|
applyControllerMargins(controller);
|
||||||
|
|
||||||
|
return normalizedLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyControllerLocation(videoController, location) {
|
||||||
|
if (!videoController) return;
|
||||||
|
|
||||||
|
var controller = getControllerElement(videoController);
|
||||||
|
if (!controller) return;
|
||||||
|
|
||||||
|
videoController.controllerLocation = applyControllerLocationToElement(
|
||||||
|
controller,
|
||||||
|
location
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function captureSiteRuleBase() {
|
||||||
|
tc.siteRuleBase = {
|
||||||
|
startHidden: tc.settings.startHidden,
|
||||||
|
hideWithControls: tc.settings.hideWithControls,
|
||||||
|
hideWithControlsTimer: tc.settings.hideWithControlsTimer,
|
||||||
|
controllerLocation: tc.settings.controllerLocation,
|
||||||
|
rememberSpeed: tc.settings.rememberSpeed,
|
||||||
|
forceLastSavedSpeed: tc.settings.forceLastSavedSpeed,
|
||||||
|
audioBoolean: tc.settings.audioBoolean,
|
||||||
|
controllerOpacity: tc.settings.controllerOpacity,
|
||||||
|
controllerMarginTop: tc.settings.controllerMarginTop,
|
||||||
|
controllerMarginBottom: tc.settings.controllerMarginBottom,
|
||||||
|
enableSubtitleNudge: tc.settings.enableSubtitleNudge,
|
||||||
|
subtitleNudgeInterval: tc.settings.subtitleNudgeInterval,
|
||||||
|
controllerButtons: Array.isArray(tc.settings.controllerButtons)
|
||||||
|
? tc.settings.controllerButtons.slice()
|
||||||
|
: tc.settings.controllerButtons,
|
||||||
|
keyBindings: Array.isArray(tc.settings.keyBindings)
|
||||||
|
? tc.settings.keyBindings.map(function (binding) {
|
||||||
|
return Object.assign({}, binding);
|
||||||
|
})
|
||||||
|
: tc.settings.keyBindings
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetSettingsFromSiteRuleBase() {
|
||||||
|
if (!tc.siteRuleBase) return;
|
||||||
|
var base = tc.siteRuleBase;
|
||||||
|
tc.settings.startHidden = base.startHidden;
|
||||||
|
tc.settings.hideWithControls = base.hideWithControls;
|
||||||
|
tc.settings.hideWithControlsTimer = base.hideWithControlsTimer;
|
||||||
|
tc.settings.controllerLocation = base.controllerLocation;
|
||||||
|
tc.settings.rememberSpeed = base.rememberSpeed;
|
||||||
|
tc.settings.forceLastSavedSpeed = base.forceLastSavedSpeed;
|
||||||
|
tc.settings.audioBoolean = base.audioBoolean;
|
||||||
|
tc.settings.controllerOpacity = base.controllerOpacity;
|
||||||
|
tc.settings.controllerMarginTop = base.controllerMarginTop;
|
||||||
|
tc.settings.controllerMarginBottom = base.controllerMarginBottom;
|
||||||
|
tc.settings.enableSubtitleNudge = base.enableSubtitleNudge;
|
||||||
|
tc.settings.subtitleNudgeInterval = base.subtitleNudgeInterval;
|
||||||
|
tc.settings.controllerButtons = Array.isArray(base.controllerButtons)
|
||||||
|
? base.controllerButtons.slice()
|
||||||
|
: base.controllerButtons;
|
||||||
|
tc.settings.keyBindings = Array.isArray(base.keyBindings)
|
||||||
|
? base.keyBindings.map(function (binding) {
|
||||||
|
return Object.assign({}, binding);
|
||||||
|
})
|
||||||
|
: base.keyBindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearManualControllerPosition(videoController) {
|
||||||
|
if (!videoController) return;
|
||||||
|
applyControllerLocation(
|
||||||
|
videoController,
|
||||||
|
videoController.controllerLocation || tc.settings.controllerLocation
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertControllerToManualPosition(videoController) {
|
||||||
|
if (!videoController) return null;
|
||||||
|
|
||||||
|
var controller = getControllerElement(videoController);
|
||||||
|
if (!controller) return null;
|
||||||
|
|
||||||
|
controller.dataset.positionMode = "manual";
|
||||||
|
|
||||||
|
var offsetParent = controller.offsetParent;
|
||||||
|
if (offsetParent) {
|
||||||
|
var controllerRect = controller.getBoundingClientRect();
|
||||||
|
var offsetParentRect = offsetParent.getBoundingClientRect();
|
||||||
|
|
||||||
|
controller.style.setProperty(
|
||||||
|
"left",
|
||||||
|
controllerRect.left - offsetParentRect.left + "px",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
|
controller.style.setProperty(
|
||||||
|
"top",
|
||||||
|
controllerRect.top - offsetParentRect.top + "px",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
controller.style.setProperty(
|
||||||
|
"left",
|
||||||
|
controller.offsetLeft + "px",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
|
controller.style.setProperty(
|
||||||
|
"top",
|
||||||
|
controller.offsetTop + "px",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
controller.style.setProperty("transform", "none", "important");
|
||||||
|
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cycleControllerLocation(video) {
|
||||||
|
if (!video || !video.vsc) return;
|
||||||
|
|
||||||
|
video.vsc.controllerLocation = getNextControllerLocation(
|
||||||
|
video.vsc.controllerLocation || tc.settings.controllerLocation
|
||||||
|
);
|
||||||
|
clearManualControllerPosition(video.vsc);
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeBindingKey(key) {
|
||||||
|
if (typeof key !== "string" || key.length === 0) return null;
|
||||||
|
if (key === "Spacebar") return " ";
|
||||||
|
if (key === "Esc") return "Escape";
|
||||||
|
if (key.length === 1 && /[a-z]/i.test(key)) return key.toUpperCase();
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
function legacyKeyCodeToBinding(keyCode) {
|
||||||
|
if (!Number.isInteger(keyCode)) return null;
|
||||||
|
var key = keyCodeToEventKey[keyCode];
|
||||||
|
if (!key && keyCode >= 48 && keyCode <= 57) {
|
||||||
|
key = String.fromCharCode(keyCode);
|
||||||
|
}
|
||||||
|
if (!key && keyCode >= 65 && keyCode <= 90) {
|
||||||
|
key = String.fromCharCode(keyCode);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
key: normalizeBindingKey(key),
|
||||||
|
keyCode: keyCode,
|
||||||
|
code: null,
|
||||||
|
disabled: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeStoredBinding(binding, fallbackKeyCode) {
|
||||||
|
var fallbackBinding = legacyKeyCodeToBinding(fallbackKeyCode);
|
||||||
|
if (!binding) return fallbackBinding;
|
||||||
|
|
||||||
|
if (
|
||||||
|
binding.disabled === true ||
|
||||||
|
(binding.key === null &&
|
||||||
|
binding.keyCode === null &&
|
||||||
|
binding.code === null)
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
action: binding.action,
|
||||||
|
key: null,
|
||||||
|
keyCode: null,
|
||||||
|
code: null,
|
||||||
|
disabled: true,
|
||||||
|
value: Number(binding.value),
|
||||||
|
force: String(binding.force) === "true" ? "true" : "false",
|
||||||
|
predefined: Boolean(binding.predefined)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var normalized = {
|
||||||
|
action: binding.action,
|
||||||
|
key: null,
|
||||||
|
keyCode: null,
|
||||||
|
code:
|
||||||
|
typeof binding.code === "string" && binding.code.length > 0
|
||||||
|
? binding.code
|
||||||
|
: null,
|
||||||
|
disabled: false,
|
||||||
|
value: Number(binding.value),
|
||||||
|
force: String(binding.force) === "true" ? "true" : "false",
|
||||||
|
predefined: Boolean(binding.predefined)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof binding.key === "string") {
|
||||||
|
normalized.key = normalizeBindingKey(binding.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
var legacyKeyCode = getLegacyKeyCode(binding);
|
||||||
|
if (Number.isInteger(legacyKeyCode)) {
|
||||||
|
var legacyBinding = legacyKeyCodeToBinding(legacyKeyCode);
|
||||||
|
if (legacyBinding) {
|
||||||
|
normalized.key = normalized.key || legacyBinding.key;
|
||||||
|
normalized.keyCode = legacyKeyCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Number.isInteger(binding.keyCode)) {
|
||||||
|
normalized.keyCode = binding.keyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!normalized.key && fallbackBinding) {
|
||||||
|
normalized.key = fallbackBinding.key;
|
||||||
|
if (normalized.keyCode === null) normalized.keyCode = fallbackBinding.keyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!normalized.key && !normalized.code && normalized.keyCode === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidSpeed(speed) {
|
||||||
|
return !isNaN(speed) && speed >= MIN_SPEED && speed <= MAX_SPEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sanitizeSpeed(speed, fallback) {
|
||||||
|
var numericSpeed = Number(speed);
|
||||||
|
return isValidSpeed(numericSpeed) ? numericSpeed : fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVideoSourceKey(video) {
|
||||||
|
return (video && (video.currentSrc || video.src)) || "unknown_src";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getControllerTargetSpeed(video) {
|
||||||
|
if (!video || !video.vsc) return null;
|
||||||
|
if (!isValidSpeed(video.vsc.targetSpeed)) return null;
|
||||||
|
|
||||||
|
var currentSourceKey = getVideoSourceKey(video);
|
||||||
|
var targetSourceKey = video.vsc.targetSpeedSourceKey;
|
||||||
|
|
||||||
|
// SPA sites (e.g. YouTube) can reuse the same <video> element.
|
||||||
|
// Don't carry controller target speed across a source swap.
|
||||||
|
if (
|
||||||
|
targetSourceKey &&
|
||||||
|
currentSourceKey === "unknown_src" &&
|
||||||
|
targetSourceKey !== "unknown_src"
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
targetSourceKey &&
|
||||||
|
currentSourceKey !== "unknown_src" &&
|
||||||
|
targetSourceKey !== currentSourceKey
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return video.vsc.targetSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRememberedSpeed(video) {
|
||||||
|
if (!tc.settings.rememberSpeed && !tc.settings.forceLastSavedSpeed) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sourceKey = getVideoSourceKey(video);
|
||||||
|
if (sourceKey !== "unknown_src") {
|
||||||
|
var videoSpeed = tc.settings.speeds[sourceKey];
|
||||||
|
if (isValidSpeed(videoSpeed)) return videoSpeed;
|
||||||
|
}
|
||||||
|
if (tc.settings.forceLastSavedSpeed && isValidSpeed(tc.settings.lastSpeed)) {
|
||||||
|
return tc.settings.lastSpeed;
|
||||||
|
}
|
||||||
|
if (tc.settings.rememberSpeed && isValidSpeed(tc.settings.lastSpeed)) {
|
||||||
|
return tc.settings.lastSpeed;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDesiredSpeed(video) {
|
||||||
|
return getControllerTargetSpeed(video) || getRememberedSpeed(video) || 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isOnYouTube() {
|
||||||
|
return (
|
||||||
|
location.hostname.includes("youtube.com") ||
|
||||||
|
location.hostname.includes("youtube-nocookie.com")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isYouTubeNativeSpeedRange(speed) {
|
||||||
|
if (speed < YT_NATIVE_MIN || speed > YT_NATIVE_MAX) return false;
|
||||||
|
// Check if speed is a multiple of 0.05 (with floating point tolerance)
|
||||||
|
var remainder = Math.abs((speed * 100) % (YT_NATIVE_STEP * 100));
|
||||||
|
return remainder < 0.01 || remainder > (YT_NATIVE_STEP * 100 - 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tryYouTubeNativeSpeed(video, speed) {
|
||||||
|
if (!isOnYouTube() || !isYouTubeNativeSpeedRange(speed)) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// YouTube's movie_player element exposes setPlaybackRate() but it's a
|
||||||
|
// page-level JS method, not a native DOM method. Content scripts can't
|
||||||
|
// see it directly. In Firefox, wrappedJSObject gives access to the
|
||||||
|
// page's JS context.
|
||||||
|
var playerEl =
|
||||||
|
video.closest(".html5-video-player") ||
|
||||||
|
document.getElementById("movie_player");
|
||||||
|
if (!playerEl) return false;
|
||||||
|
|
||||||
|
// Try wrappedJSObject first (Firefox content script → page context)
|
||||||
|
var player = playerEl.wrappedJSObject || playerEl;
|
||||||
|
if (typeof player.setPlaybackRate === "function") {
|
||||||
|
player.setPlaybackRate(speed);
|
||||||
|
// Verify YouTube actually accepted the speed (it may silently clamp)
|
||||||
|
var actualSpeed = video.playbackRate;
|
||||||
|
if (Math.abs(actualSpeed - speed) > 0.01) {
|
||||||
|
log("YouTube clamped speed to " + actualSpeed + ", falling back", 4);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
log("Used YouTube native setPlaybackRate: " + speed, 4);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log("YouTube native speed failed: " + e.message, 3);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSubtitleNudgeSupported(video) {
|
||||||
|
return Boolean(video);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSubtitleNudgeEnabledForVideo(video) {
|
||||||
|
if (!video || !video.vsc) return tc.settings.enableSubtitleNudge;
|
||||||
|
|
||||||
|
if (typeof video.vsc.subtitleNudgeEnabledOverride === "boolean") {
|
||||||
|
return video.vsc.subtitleNudgeEnabledOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tc.settings.enableSubtitleNudge;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSubtitleNudgeEnabledForVideo(video, enabled) {
|
||||||
|
if (!video || !video.vsc) return false;
|
||||||
|
|
||||||
|
var normalizedEnabled = Boolean(enabled);
|
||||||
|
video.vsc.subtitleNudgeEnabledOverride = normalizedEnabled;
|
||||||
|
|
||||||
|
if (!normalizedEnabled) {
|
||||||
|
video.vsc.stopSubtitleNudge();
|
||||||
|
} else if (!video.paused && video.playbackRate !== 1.0) {
|
||||||
|
video.vsc.startSubtitleNudge();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSubtitleNudgeIndicator(video);
|
||||||
|
|
||||||
|
// Briefly flash the standalone indicator next to the speed text
|
||||||
|
var flashEl = video.vsc.nudgeFlashIndicator;
|
||||||
|
if (flashEl) {
|
||||||
|
flashEl.classList.add("visible");
|
||||||
|
clearTimeout(flashEl._flashTimer);
|
||||||
|
flashEl._flashTimer = setTimeout(function () {
|
||||||
|
flashEl.classList.remove("visible");
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizedEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSubtitleNudgeIndicatorContent(target, isEnabled) {
|
||||||
|
if (!target) return;
|
||||||
|
var action = isEnabled ? "subtitleNudgeOn" : "subtitleNudgeOff";
|
||||||
|
var custom =
|
||||||
|
tc.settings.customButtonIcons &&
|
||||||
|
tc.settings.customButtonIcons[action] &&
|
||||||
|
tc.settings.customButtonIcons[action].svg;
|
||||||
|
vscClearElement(target);
|
||||||
|
if (custom) {
|
||||||
|
var customWrap = vscCreateSvgWrap(
|
||||||
|
target.ownerDocument || document,
|
||||||
|
custom,
|
||||||
|
"vsc-btn-icon"
|
||||||
|
);
|
||||||
|
if (customWrap) {
|
||||||
|
target.appendChild(customWrap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof vscIconSvgString !== "function") {
|
||||||
|
target.textContent = isEnabled ? "✓" : "×";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var svg = vscIconSvgString(action, 14);
|
||||||
|
if (!svg) {
|
||||||
|
target.textContent = isEnabled ? "✓" : "×";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var wrap = vscCreateSvgWrap(target.ownerDocument || document, svg, "vsc-btn-icon");
|
||||||
|
if (wrap) {
|
||||||
|
target.appendChild(wrap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
target.textContent = isEnabled ? "✓" : "×";
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSubtitleNudgeIndicator(video) {
|
||||||
|
if (!video || !video.vsc) return;
|
||||||
|
|
||||||
|
var isEnabled = isSubtitleNudgeEnabledForVideo(video);
|
||||||
|
var title = isEnabled ? "Subtitle nudge enabled" : "Subtitle nudge disabled";
|
||||||
|
|
||||||
|
var indicator = video.vsc.subtitleNudgeIndicator;
|
||||||
|
if (indicator) {
|
||||||
|
renderSubtitleNudgeIndicatorContent(indicator, isEnabled);
|
||||||
|
indicator.dataset.enabled = isEnabled ? "true" : "false";
|
||||||
|
indicator.dataset.supported = "true";
|
||||||
|
indicator.title = title;
|
||||||
|
indicator.setAttribute("aria-label", title);
|
||||||
|
}
|
||||||
|
|
||||||
|
var flashEl = video.vsc.nudgeFlashIndicator;
|
||||||
|
if (flashEl) {
|
||||||
|
renderSubtitleNudgeIndicatorContent(flashEl, isEnabled);
|
||||||
|
flashEl.dataset.enabled = isEnabled ? "true" : "false";
|
||||||
|
flashEl.dataset.supported = "true";
|
||||||
|
flashEl.setAttribute("aria-label", title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function schedulePersistLastSpeed(speed) {
|
||||||
|
if (!isValidSpeed(speed)) return;
|
||||||
|
|
||||||
|
tc.pendingLastSpeedValue = speed;
|
||||||
|
if (tc.pendingLastSpeedSave !== null) return;
|
||||||
|
|
||||||
|
tc.pendingLastSpeedSave = setTimeout(function () {
|
||||||
|
var speedToPersist = tc.pendingLastSpeedValue;
|
||||||
|
tc.pendingLastSpeedSave = null;
|
||||||
|
|
||||||
|
if (!isValidSpeed(speedToPersist) || tc.persistedLastSpeed === speedToPersist) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.storage.sync.set({ lastSpeed: speedToPersist }, function () { });
|
||||||
|
tc.persistedLastSpeed = speedToPersist;
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
function suppressNextNudgeRateChanges(controller, count) {
|
||||||
|
if (!controller) return;
|
||||||
|
|
||||||
|
controller.suppressedRateChangeCount =
|
||||||
|
(controller.suppressedRateChangeCount || 0) + (count || 2);
|
||||||
|
controller.suppressedRateChangeUntil =
|
||||||
|
Date.now() + Math.max(250, tc.settings.subtitleNudgeInterval * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldIgnoreSuppressedRateChange(video) {
|
||||||
|
if (!video || !video.vsc) return false;
|
||||||
|
|
||||||
|
var controller = video.vsc;
|
||||||
|
if (
|
||||||
|
controller.suppressedRateChangeCount > 0 &&
|
||||||
|
controller.suppressedRateChangeUntil >= Date.now()
|
||||||
|
) {
|
||||||
|
controller.suppressedRateChangeCount -= 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controller.suppressedRateChangeUntil < Date.now()) {
|
||||||
|
controller.suppressedRateChangeCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveTargetSpeed(video) {
|
||||||
|
return getDesiredSpeed(video);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applySourceTransitionPolicy(video, forceUpdate) {
|
||||||
|
if (!video || !video.vsc) return;
|
||||||
|
|
||||||
|
var sourceKey = getVideoSourceKey(video);
|
||||||
|
if (!forceUpdate && video.vsc.mediaSourceKey === sourceKey) return;
|
||||||
|
|
||||||
|
video.vsc.mediaSourceKey = sourceKey;
|
||||||
|
|
||||||
|
var desiredSpeed =
|
||||||
|
tc.settings.rememberSpeed || tc.settings.forceLastSavedSpeed
|
||||||
|
? sanitizeSpeed(tc.settings.lastSpeed, 1.0)
|
||||||
|
: 1.0;
|
||||||
|
|
||||||
|
video.vsc.targetSpeed = desiredSpeed;
|
||||||
|
video.vsc.targetSpeedSourceKey = sourceKey;
|
||||||
|
if (video.vsc.speedIndicator) {
|
||||||
|
video.vsc.speedIndicator.textContent = desiredSpeed.toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Math.abs(video.playbackRate - desiredSpeed) > 0.01) {
|
||||||
|
setSpeed(video, desiredSpeed, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same-tab SPA (e.g. YouTube watch → Shorts): URL can change while remember-speed
|
||||||
|
// already ran on src mutation — re-apply margins / location / opacity for new rules.
|
||||||
|
reapplySiteRulesAndControllerGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
function extendSpeedRestoreWindow(video, duration) {
|
||||||
|
if (!video || !video.vsc) return;
|
||||||
|
|
||||||
|
var restoreDuration = Number(duration) || 1500;
|
||||||
|
var restoreUntil = Date.now() + restoreDuration;
|
||||||
|
var currentUntil = Number(video.vsc.speedRestoreUntil) || 0;
|
||||||
|
|
||||||
|
video.vsc.speedRestoreUntil = Math.max(currentUntil, restoreUntil);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scheduleSpeedRestore(video, desiredSpeed, reason) {
|
||||||
|
if (!video || !video.vsc || !isValidSpeed(desiredSpeed)) return;
|
||||||
|
|
||||||
|
if (video.vsc.restoreSpeedTimer) {
|
||||||
|
clearTimeout(video.vsc.restoreSpeedTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
video.vsc.restoreSpeedTimer = setTimeout(function () {
|
||||||
|
if (!video.vsc) return;
|
||||||
|
|
||||||
|
if (Math.abs(video.playbackRate - desiredSpeed) > 0.01) {
|
||||||
|
log(
|
||||||
|
`Restoring playbackRate to ${desiredSpeed.toFixed(2)} after ${reason}`,
|
||||||
|
4
|
||||||
|
);
|
||||||
|
setSpeed(video, desiredSpeed, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (video.vsc) {
|
||||||
|
video.vsc.restoreSpeedTimer = null;
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberPendingRateChange(video, speed) {
|
||||||
|
if (!video || !video.vsc || !isValidSpeed(speed)) return;
|
||||||
|
|
||||||
|
video.vsc.pendingRateChange = {
|
||||||
|
speed: Number(speed),
|
||||||
|
expiresAt: Date.now() + 1000
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function takePendingRateChange(video, currentSpeed) {
|
||||||
|
if (!video || !video.vsc || !video.vsc.pendingRateChange) return null;
|
||||||
|
|
||||||
|
var pendingRateChange = video.vsc.pendingRateChange;
|
||||||
|
if (
|
||||||
|
!isValidSpeed(pendingRateChange.speed) ||
|
||||||
|
pendingRateChange.expiresAt <= Date.now()
|
||||||
|
) {
|
||||||
|
video.vsc.pendingRateChange = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Math.abs(Number(pendingRateChange.speed) - currentSpeed) > 0.01) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
video.vsc.pendingRateChange = null;
|
||||||
|
return pendingRateChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesKeyBinding(binding, event) {
|
||||||
|
if (!binding || binding.disabled) return false;
|
||||||
|
|
||||||
|
var normalizedEventKey = normalizeBindingKey(event.key);
|
||||||
|
if (binding.key && normalizedEventKey) {
|
||||||
|
return binding.key === normalizedEventKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binding.code && event.code) {
|
||||||
|
return binding.code === event.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
var legacyKeyCode = getLegacyKeyCode(binding);
|
||||||
|
return Number.isInteger(legacyKeyCode) && legacyKeyCode === event.keyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mediaSelector() {
|
||||||
|
return tc.settings.audioBoolean ? "video,audio" : "video";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isMediaElement(node) {
|
||||||
|
return (
|
||||||
|
node &&
|
||||||
|
node.nodeType === Node.ELEMENT_NODE &&
|
||||||
|
(node.nodeName === "VIDEO" ||
|
||||||
|
(node.nodeName === "AUDIO" && tc.settings.audioBoolean))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasUsableMediaSource(node) {
|
||||||
|
if (!isMediaElement(node) || !node.isConnected) return false;
|
||||||
|
if (node.currentSrc || node.src || node.srcObject) return true;
|
||||||
|
if (typeof node.readyState === "number" && node.readyState > 0) return true;
|
||||||
|
if (
|
||||||
|
typeof node.networkState === "number" &&
|
||||||
|
typeof HTMLMediaElement !== "undefined" &&
|
||||||
|
(node.networkState === HTMLMediaElement.NETWORK_IDLE ||
|
||||||
|
node.networkState === HTMLMediaElement.NETWORK_LOADING)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.querySelectorAll) {
|
||||||
|
return Array.from(node.querySelectorAll("source[src]")).some(function (
|
||||||
|
source
|
||||||
|
) {
|
||||||
|
var src = source.getAttribute("src");
|
||||||
|
return typeof src === "string" && src.trim().length > 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureController(node, parent) {
|
||||||
|
if (!isMediaElement(node) || node.vsc) return node && node.vsc;
|
||||||
|
if (!hasUsableMediaSource(node)) {
|
||||||
|
log(
|
||||||
|
`Deferring controller creation for ${node.tagName}: no usable source yet`,
|
||||||
|
5
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// href selects site rules; re-run on every new/usable media so margins/opacity match current URL.
|
||||||
|
var siteDisabled = applySiteRuleOverrides();
|
||||||
|
if (!tc.settings.enabled || siteDisabled) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
refreshAllControllerGeometry();
|
||||||
|
|
||||||
|
log(
|
||||||
|
`Creating controller for ${node.tagName}: ${node.src || node.currentSrc || "no src"}`,
|
||||||
|
4
|
||||||
|
);
|
||||||
|
node.vsc = new tc.videoController(
|
||||||
|
node,
|
||||||
|
parent || node.parentElement || node.parentNode
|
||||||
|
);
|
||||||
|
return node.vsc;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeController(node) {
|
||||||
|
if (node && node.vsc) node.vsc.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function scanNodeForMedia(node, parent, added) {
|
||||||
|
if (!node || typeof node === "function") return;
|
||||||
|
|
||||||
|
if (node.nodeType === Node.DOCUMENT_NODE) {
|
||||||
|
scanNodeForMedia(node.body || node.documentElement, node.body, added);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
node.nodeType !== Node.ELEMENT_NODE &&
|
||||||
|
node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ownerDocument = node.ownerDocument || document;
|
||||||
|
if (!added && ownerDocument.body && ownerDocument.body.contains(node)) return;
|
||||||
|
|
||||||
|
// Check if the node itself is a media element
|
||||||
|
if (isMediaElement(node)) {
|
||||||
|
if (added) ensureController(node, parent);
|
||||||
|
else removeController(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use querySelectorAll instead of recursive child walking — the browser's
|
||||||
|
// native selector engine is orders of magnitude faster than JS recursion.
|
||||||
|
if (typeof node.querySelectorAll === "function") {
|
||||||
|
var selector = mediaSelector();
|
||||||
|
try {
|
||||||
|
var mediaElements = node.querySelectorAll(selector);
|
||||||
|
for (var i = 0; i < mediaElements.length; i++) {
|
||||||
|
var el = mediaElements[i];
|
||||||
|
if (added) ensureController(el, el.parentNode || parent);
|
||||||
|
else removeController(el);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// querySelectorAll may throw on detached or unusual nodes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still need to observe shadow roots for media inside web components
|
||||||
|
if (node.shadowRoot) {
|
||||||
|
observeRoot(node.shadowRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getScanNodeForRoot(root) {
|
||||||
|
if (!root) return null;
|
||||||
|
if (root.nodeType === Node.DOCUMENT_NODE) {
|
||||||
|
return root.body || root.documentElement;
|
||||||
|
}
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rootMayContainMedia(root) {
|
||||||
|
if (!root) return false;
|
||||||
|
if (root.nodeType === Node.DOCUMENT_NODE) return true;
|
||||||
|
if (typeof root.querySelector !== "function") return true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Boolean(root.querySelector(mediaSelector()));
|
||||||
|
} catch (error) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scanRootForMedia(root) {
|
||||||
|
var scanRoot = getScanNodeForRoot(root);
|
||||||
|
if (!scanRoot) return;
|
||||||
|
scanNodeForMedia(scanRoot, root.host || scanRoot.parentNode || scanRoot, true);
|
||||||
|
if (root.nodeType === Node.DOCUMENT_NODE) {
|
||||||
|
attachIframeListeners(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function observeRoot(root) {
|
||||||
|
if (!root || vscObservedRoots.has(root)) return;
|
||||||
|
vscObservedRoots.add(root);
|
||||||
|
setupListener(root);
|
||||||
|
attachMutationObserver(root);
|
||||||
|
attachMediaDetectionListeners(root);
|
||||||
|
if (rootMayContainMedia(root)) {
|
||||||
|
scanRootForMedia(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchAttachShadow() {
|
||||||
|
if (
|
||||||
|
window.vscAttachShadowPatched ||
|
||||||
|
typeof Element === "undefined" ||
|
||||||
|
typeof Element.prototype.attachShadow !== "function"
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var originalAttachShadow = Element.prototype.attachShadow;
|
||||||
|
Element.prototype.attachShadow = function () {
|
||||||
|
var shadowRoot = originalAttachShadow.apply(this, arguments);
|
||||||
|
try {
|
||||||
|
if (shadowRoot) {
|
||||||
|
observeRoot(shadowRoot);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log(`Unable to observe shadow root: ${error.message}`, 3);
|
||||||
|
}
|
||||||
|
return shadowRoot;
|
||||||
|
};
|
||||||
|
window.vscAttachShadowPatched = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Log levels */
|
/* Log levels */
|
||||||
function log(message, level) {
|
function log(message, level) {
|
||||||
verbosity = tc.settings.logLevel;
|
verbosity = tc.settings.logLevel;
|
||||||
@@ -47,51 +1192,16 @@ function log(message, level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chrome.storage.sync.get(tc.settings, function (storage) {
|
chrome.storage.sync.get(tc.settings, function (storage) {
|
||||||
// Original initialization from your code
|
var storedBindings = Array.isArray(storage.keyBindings)
|
||||||
tc.settings.keyBindings = storage.keyBindings;
|
? storage.keyBindings
|
||||||
if (storage.keyBindings.length == 0) {
|
: [];
|
||||||
tc.settings.keyBindings.push({
|
|
||||||
action: "slower",
|
tc.settings.keyBindings = storedBindings
|
||||||
key: Number(storage.slowerKeyCode) || 83,
|
.map((binding) => normalizeStoredBinding(binding))
|
||||||
value: Number(storage.speedStep) || 0.1,
|
.filter(Boolean);
|
||||||
force: false,
|
|
||||||
predefined: true
|
if (tc.settings.keyBindings.length === 0) {
|
||||||
});
|
tc.settings.keyBindings = defaultKeyBindings(storage);
|
||||||
tc.settings.keyBindings.push({
|
|
||||||
action: "faster",
|
|
||||||
key: Number(storage.fasterKeyCode) || 68,
|
|
||||||
value: Number(storage.speedStep) || 0.1,
|
|
||||||
force: false,
|
|
||||||
predefined: true
|
|
||||||
});
|
|
||||||
tc.settings.keyBindings.push({
|
|
||||||
action: "rewind",
|
|
||||||
key: Number(storage.rewindKeyCode) || 90,
|
|
||||||
value: Number(storage.rewindTime) || 10,
|
|
||||||
force: false,
|
|
||||||
predefined: true
|
|
||||||
});
|
|
||||||
tc.settings.keyBindings.push({
|
|
||||||
action: "advance",
|
|
||||||
key: Number(storage.advanceKeyCode) || 88,
|
|
||||||
value: Number(storage.advanceTime) || 10,
|
|
||||||
force: false,
|
|
||||||
predefined: true
|
|
||||||
});
|
|
||||||
tc.settings.keyBindings.push({
|
|
||||||
action: "reset",
|
|
||||||
key: Number(storage.resetKeyCode) || 82,
|
|
||||||
value: 1.0,
|
|
||||||
force: false,
|
|
||||||
predefined: true
|
|
||||||
});
|
|
||||||
tc.settings.keyBindings.push({
|
|
||||||
action: "fast",
|
|
||||||
key: Number(storage.fastKeyCode) || 71,
|
|
||||||
value: Number(storage.fastSpeed) || 1.8,
|
|
||||||
force: false,
|
|
||||||
predefined: true
|
|
||||||
});
|
|
||||||
tc.settings.version = "0.5.3";
|
tc.settings.version = "0.5.3";
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
keyBindings: tc.settings.keyBindings,
|
keyBindings: tc.settings.keyBindings,
|
||||||
@@ -102,39 +1212,192 @@ chrome.storage.sync.get(tc.settings, function (storage) {
|
|||||||
audioBoolean: tc.settings.audioBoolean,
|
audioBoolean: tc.settings.audioBoolean,
|
||||||
startHidden: tc.settings.startHidden,
|
startHidden: tc.settings.startHidden,
|
||||||
enabled: tc.settings.enabled,
|
enabled: tc.settings.enabled,
|
||||||
controllerOpacity: tc.settings.controllerOpacity,
|
controllerLocation: tc.settings.controllerLocation,
|
||||||
blacklist: tc.settings.blacklist.replace(regStrip, "")
|
controllerOpacity: tc.settings.controllerOpacity
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
tc.settings.lastSpeed = Number(storage.lastSpeed);
|
tc.settings.lastSpeed = Number(storage.lastSpeed);
|
||||||
|
if (!isValidSpeed(tc.settings.lastSpeed) && tc.settings.lastSpeed !== 1.0) {
|
||||||
|
log(`Invalid lastSpeed detected: ${storage.lastSpeed}, resetting to 1.0`, 3);
|
||||||
|
tc.settings.lastSpeed = 1.0;
|
||||||
|
tc.persistedLastSpeed = 1.0;
|
||||||
|
chrome.storage.sync.set({ lastSpeed: 1.0 });
|
||||||
|
} else if (!isValidSpeed(tc.settings.lastSpeed)) {
|
||||||
|
tc.settings.lastSpeed = 1.0;
|
||||||
|
}
|
||||||
|
tc.persistedLastSpeed = tc.settings.lastSpeed;
|
||||||
tc.settings.displayKeyCode = Number(storage.displayKeyCode);
|
tc.settings.displayKeyCode = Number(storage.displayKeyCode);
|
||||||
tc.settings.rememberSpeed = Boolean(storage.rememberSpeed);
|
tc.settings.rememberSpeed = Boolean(storage.rememberSpeed);
|
||||||
tc.settings.forceLastSavedSpeed = Boolean(storage.forceLastSavedSpeed);
|
tc.settings.forceLastSavedSpeed = Boolean(storage.forceLastSavedSpeed);
|
||||||
tc.settings.audioBoolean = Boolean(storage.audioBoolean);
|
tc.settings.audioBoolean = Boolean(storage.audioBoolean);
|
||||||
tc.settings.enabled = Boolean(storage.enabled);
|
tc.settings.enabled = Boolean(storage.enabled);
|
||||||
tc.settings.startHidden = Boolean(storage.startHidden);
|
tc.settings.startHidden = Boolean(storage.startHidden);
|
||||||
|
tc.settings.hideWithControls =
|
||||||
|
typeof storage.hideWithControls !== "undefined"
|
||||||
|
? Boolean(storage.hideWithControls)
|
||||||
|
: Boolean(storage.hideWithYouTubeControls);
|
||||||
|
tc.settings.hideWithControlsTimer =
|
||||||
|
Math.min(15, Math.max(0.1, Number(storage.hideWithControlsTimer) || 2.0));
|
||||||
|
tc.settings.hideWithYouTubeControls = tc.settings.hideWithControls;
|
||||||
|
tc.settings.controllerLocation = normalizeControllerLocation(
|
||||||
|
storage.controllerLocation
|
||||||
|
);
|
||||||
tc.settings.controllerOpacity = Number(storage.controllerOpacity);
|
tc.settings.controllerOpacity = Number(storage.controllerOpacity);
|
||||||
tc.settings.blacklist = String(storage.blacklist);
|
tc.settings.controllerMarginTop = normalizeControllerMarginPx(
|
||||||
|
storage.controllerMarginTop,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
tc.settings.controllerMarginRight = normalizeControllerMarginPx(
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
tc.settings.controllerMarginBottom = normalizeControllerMarginPx(
|
||||||
|
storage.controllerMarginBottom,
|
||||||
|
typeof storage.controllerMarginBottom !== "undefined" ? 0 : 65
|
||||||
|
);
|
||||||
|
tc.settings.controllerMarginLeft = normalizeControllerMarginPx(
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
tc.settings.siteRules = Array.isArray(storage.siteRules)
|
||||||
|
? storage.siteRules
|
||||||
|
: [];
|
||||||
|
|
||||||
|
tc.settings.controllerButtons = Array.isArray(storage.controllerButtons)
|
||||||
|
? storage.controllerButtons
|
||||||
|
: tc.settings.controllerButtons;
|
||||||
|
|
||||||
tc.settings.enableSubtitleNudge =
|
tc.settings.enableSubtitleNudge =
|
||||||
typeof storage.enableSubtitleNudge !== "undefined"
|
typeof storage.enableSubtitleNudge !== "undefined"
|
||||||
? Boolean(storage.enableSubtitleNudge)
|
? Boolean(storage.enableSubtitleNudge)
|
||||||
: tc.settings.enableSubtitleNudge;
|
: tc.settings.enableSubtitleNudge;
|
||||||
tc.settings.subtitleNudgeInterval =
|
tc.settings.subtitleNudgeInterval = Math.min(
|
||||||
Number(storage.subtitleNudgeInterval) || 25;
|
1000,
|
||||||
|
Math.max(10, Number(storage.subtitleNudgeInterval) || 50)
|
||||||
|
);
|
||||||
tc.settings.subtitleNudgeAmount =
|
tc.settings.subtitleNudgeAmount =
|
||||||
Number(storage.subtitleNudgeAmount) || tc.settings.subtitleNudgeAmount;
|
Number(storage.subtitleNudgeAmount) || tc.settings.subtitleNudgeAmount;
|
||||||
if (
|
var addedDefaultBinding = false;
|
||||||
tc.settings.keyBindings.filter((x) => x.action == "display").length == 0
|
addedDefaultBinding =
|
||||||
) {
|
ensureDefaultKeyBinding(
|
||||||
tc.settings.keyBindings.push({
|
"display",
|
||||||
action: "display",
|
"V",
|
||||||
key: Number(storage.displayKeyCode) || 86,
|
Number(storage.displayKeyCode) || 86,
|
||||||
value: 0,
|
0
|
||||||
force: false,
|
) || addedDefaultBinding;
|
||||||
predefined: true
|
addedDefaultBinding =
|
||||||
});
|
ensureDefaultKeyBinding("move", "P", 80, 0) || addedDefaultBinding;
|
||||||
|
addedDefaultBinding =
|
||||||
|
ensureDefaultKeyBinding("toggleSubtitleNudge", "N", 78, 0) ||
|
||||||
|
addedDefaultBinding;
|
||||||
|
|
||||||
|
if (addedDefaultBinding) {
|
||||||
|
chrome.storage.sync.set({ keyBindings: tc.settings.keyBindings });
|
||||||
}
|
}
|
||||||
initializeWhenReady(document);
|
captureSiteRuleBase();
|
||||||
|
patchAttachShadow();
|
||||||
|
// Add a listener for messages from the popup.
|
||||||
|
// We use a global flag to ensure the listener is only attached once.
|
||||||
|
if (!window.vscMessageListener) {
|
||||||
|
chrome.runtime.onMessage.addListener(
|
||||||
|
function (request, sender, sendResponse) {
|
||||||
|
if (request.action === "rescan_page") {
|
||||||
|
log("Re-scan command received from popup.", 4);
|
||||||
|
initializeWhenReady(document, true);
|
||||||
|
sendResponse({ status: "complete" });
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (request.action === "get_speed") {
|
||||||
|
// Do not sendResponse in frames with no media — only one response is
|
||||||
|
// accepted tab-wide, and the top frame often wins before an iframe.
|
||||||
|
var videoGs = getPrimaryVideoElement();
|
||||||
|
if (!videoGs) return false;
|
||||||
|
sendResponse({
|
||||||
|
speed: videoGs.playbackRate
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (request.action === "get_page_context") {
|
||||||
|
sendResponse({ url: location.href });
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (request.action === "run_action") {
|
||||||
|
var value = request.value;
|
||||||
|
if (value === undefined || value === null) {
|
||||||
|
value = getKeyBindings(request.actionName, "value");
|
||||||
|
}
|
||||||
|
runAction(request.actionName, value);
|
||||||
|
var videoAfter = getPrimaryVideoElement();
|
||||||
|
if (!videoAfter) return false;
|
||||||
|
sendResponse({
|
||||||
|
speed: videoAfter.playbackRate
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set the flag to prevent adding the listener again.
|
||||||
|
window.vscMessageListener = true;
|
||||||
|
}
|
||||||
|
chrome.storage.local.get(["customButtonIcons"], function (loc) {
|
||||||
|
tc.settings.customButtonIcons =
|
||||||
|
loc &&
|
||||||
|
loc.customButtonIcons &&
|
||||||
|
typeof loc.customButtonIcons === "object"
|
||||||
|
? loc.customButtonIcons
|
||||||
|
: {};
|
||||||
|
|
||||||
|
if (!window.vscCustomIconListener) {
|
||||||
|
window.vscCustomIconListener = true;
|
||||||
|
chrome.storage.onChanged.addListener(function (changes, area) {
|
||||||
|
if (area !== "local" || !changes.customButtonIcons) return;
|
||||||
|
var nv = changes.customButtonIcons.newValue;
|
||||||
|
tc.settings.customButtonIcons =
|
||||||
|
nv && typeof nv === "object" ? nv : {};
|
||||||
|
if (tc.mediaElements && tc.mediaElements.length) {
|
||||||
|
tc.mediaElements.forEach(function (video) {
|
||||||
|
if (!video.vsc || !video.vsc.div) return;
|
||||||
|
var doc = video.ownerDocument;
|
||||||
|
var shadow = video.vsc.div.shadowRoot;
|
||||||
|
if (!shadow) return;
|
||||||
|
shadow.querySelectorAll("button[data-action]").forEach(function (btn) {
|
||||||
|
var act = btn.dataset.action;
|
||||||
|
if (!act) return;
|
||||||
|
var svg =
|
||||||
|
tc.settings.customButtonIcons &&
|
||||||
|
tc.settings.customButtonIcons[act] &&
|
||||||
|
tc.settings.customButtonIcons[act].svg;
|
||||||
|
vscClearElement(btn);
|
||||||
|
if (svg) {
|
||||||
|
var cw = vscCreateSvgWrap(doc, svg, "vsc-btn-icon");
|
||||||
|
if (cw) {
|
||||||
|
btn.appendChild(cw);
|
||||||
|
} else {
|
||||||
|
var cdf = controllerButtonDefs[act];
|
||||||
|
btn.textContent = (cdf && cdf.label) || "?";
|
||||||
|
}
|
||||||
|
} else if (typeof vscIconWrap === "function") {
|
||||||
|
var wrap = vscIconWrap(doc, act, 14);
|
||||||
|
if (wrap) {
|
||||||
|
btn.appendChild(wrap);
|
||||||
|
} else {
|
||||||
|
var cdf = controllerButtonDefs[act];
|
||||||
|
btn.textContent = (cdf && cdf.label) || "?";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var cdf2 = controllerButtonDefs[act];
|
||||||
|
btn.textContent = (cdf2 && cdf2.label) || "?";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
updateSubtitleNudgeIndicator(video);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initializeWhenReady(document);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getKeyBindings(action, what = "value") {
|
function getKeyBindings(action, what = "value") {
|
||||||
@@ -149,6 +1412,36 @@ function setKeyBindings(action, value) {
|
|||||||
value;
|
value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createControllerButton(doc, action, label, className) {
|
||||||
|
var button = doc.createElement("button");
|
||||||
|
button.dataset.action = action;
|
||||||
|
var custom =
|
||||||
|
tc.settings.customButtonIcons &&
|
||||||
|
tc.settings.customButtonIcons[action] &&
|
||||||
|
tc.settings.customButtonIcons[action].svg;
|
||||||
|
if (custom) {
|
||||||
|
var customWrap = vscCreateSvgWrap(doc, custom, "vsc-btn-icon");
|
||||||
|
if (customWrap) {
|
||||||
|
button.appendChild(customWrap);
|
||||||
|
} else {
|
||||||
|
button.textContent = label || "?";
|
||||||
|
}
|
||||||
|
} else if (typeof vscIconWrap === "function") {
|
||||||
|
var wrap = vscIconWrap(doc, action, 14);
|
||||||
|
if (wrap) {
|
||||||
|
button.appendChild(wrap);
|
||||||
|
} else {
|
||||||
|
button.textContent = label || "?";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
button.textContent = label || "?";
|
||||||
|
}
|
||||||
|
if (className) {
|
||||||
|
button.className = className;
|
||||||
|
}
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
function defineVideoController() {
|
function defineVideoController() {
|
||||||
tc.videoController = function (target, parent) {
|
tc.videoController = function (target, parent) {
|
||||||
if (target.vsc) return target.vsc;
|
if (target.vsc) return target.vsc;
|
||||||
@@ -156,37 +1449,111 @@ 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;
|
||||||
let storedSpeed = tc.settings.speeds[target.currentSrc];
|
this.restoreSpeedTimer = null;
|
||||||
if (!tc.settings.rememberSpeed) {
|
this.pendingRateChange = null;
|
||||||
if (!storedSpeed) {
|
this.speedRestoreUntil = 0;
|
||||||
storedSpeed = 1.0;
|
this.subtitleNudgeEnabledOverride = null;
|
||||||
}
|
this.suppressedRateChangeCount = 0;
|
||||||
|
this.suppressedRateChangeUntil = 0;
|
||||||
|
this.visibilityResumeHandler = null;
|
||||||
|
this.resetToggleArmed = false;
|
||||||
|
this.resetButtonEl = null;
|
||||||
|
this.controllerLocation = normalizeControllerLocation(
|
||||||
|
tc.settings.controllerLocation
|
||||||
|
);
|
||||||
|
|
||||||
|
log(`Creating video controller for ${target.tagName} with src: ${target.src || target.currentSrc || 'none'}`, 4);
|
||||||
|
|
||||||
|
let storedSpeed = sanitizeSpeed(resolveTargetSpeed(target), 1.0);
|
||||||
|
this.targetSpeed = storedSpeed;
|
||||||
|
this.targetSpeedSourceKey = getVideoSourceKey(target);
|
||||||
|
this.mediaSourceKey = getVideoSourceKey(target);
|
||||||
|
if (!tc.settings.rememberSpeed && !tc.settings.forceLastSavedSpeed) {
|
||||||
setKeyBindings("reset", getKeyBindings("fast"));
|
setKeyBindings("reset", getKeyBindings("fast"));
|
||||||
} else {
|
|
||||||
storedSpeed = tc.settings.lastSpeed;
|
|
||||||
}
|
|
||||||
if (tc.settings.forceLastSavedSpeed) {
|
|
||||||
storedSpeed = tc.settings.lastSpeed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log("Explicitly setting playbackRate to: " + storedSpeed, 5);
|
||||||
target.playbackRate = storedSpeed;
|
target.playbackRate = storedSpeed;
|
||||||
|
|
||||||
this.div = this.initializeControls();
|
this.div = this.initializeControls();
|
||||||
|
|
||||||
|
if (!this.div) {
|
||||||
|
log("ERROR: Failed to create controller div!", 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log(`Controller created and attached to DOM. Hidden: ${this.div.classList.contains('vsc-hidden')}`, 4);
|
||||||
|
|
||||||
var mediaEventAction = function (event) {
|
var mediaEventAction = function (event) {
|
||||||
let storedSpeed = tc.settings.speeds[event.target.currentSrc];
|
if (
|
||||||
if (!tc.settings.rememberSpeed) {
|
event.type === "loadedmetadata" ||
|
||||||
if (!storedSpeed) {
|
event.type === "loadeddata" ||
|
||||||
storedSpeed = 1.0;
|
event.type === "canplay"
|
||||||
}
|
) {
|
||||||
setKeyBindings("reset", getKeyBindings("fast"));
|
applySourceTransitionPolicy(event.target, false);
|
||||||
} else {
|
|
||||||
storedSpeed = tc.settings.lastSpeed;
|
|
||||||
}
|
}
|
||||||
if (tc.settings.forceLastSavedSpeed) storedSpeed = tc.settings.lastSpeed;
|
|
||||||
setSpeed(event.target, storedSpeed);
|
if (event.type === "play") {
|
||||||
if (event.type === "play") this.startSubtitleNudge();
|
applySourceTransitionPolicy(event.target, false);
|
||||||
else if (event.type === "pause" || event.type === "ended")
|
extendSpeedRestoreWindow(event.target);
|
||||||
|
|
||||||
|
if (!tc.settings.rememberSpeed && !tc.settings.forceLastSavedSpeed) {
|
||||||
|
setKeyBindings("reset", getKeyBindings("fast"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var playSpeed = sanitizeSpeed(resolveTargetSpeed(event.target), 1.0);
|
||||||
|
if (Math.abs(event.target.playbackRate - playSpeed) > 0.01) {
|
||||||
|
log("Play event: setting playbackRate to: " + playSpeed, 4);
|
||||||
|
setSpeed(event.target, playSpeed, false, false);
|
||||||
|
} else if (playSpeed === 1.0 || event.target.paused) {
|
||||||
|
this.stopSubtitleNudge();
|
||||||
|
} else {
|
||||||
|
this.startSubtitleNudge();
|
||||||
|
}
|
||||||
|
} else if (event.type === "pause") {
|
||||||
|
extendSpeedRestoreWindow(event.target);
|
||||||
this.stopSubtitleNudge();
|
this.stopSubtitleNudge();
|
||||||
|
tc.isNudging = false;
|
||||||
|
} else if (event.type === "seeking") {
|
||||||
|
extendSpeedRestoreWindow(event.target);
|
||||||
|
} else if (event.type === "ended") {
|
||||||
|
this.speedRestoreUntil = 0;
|
||||||
|
this.stopSubtitleNudge();
|
||||||
|
tc.isNudging = false;
|
||||||
|
} else if (event.type === "seeked") {
|
||||||
|
extendSpeedRestoreWindow(event.target);
|
||||||
|
var expectedSpeed = sanitizeSpeed(resolveTargetSpeed(event.target), 1.0);
|
||||||
|
var currentSpeed = event.target.playbackRate;
|
||||||
|
|
||||||
|
if (
|
||||||
|
Math.abs(currentSpeed - expectedSpeed) > 0.01
|
||||||
|
) {
|
||||||
|
log(
|
||||||
|
`Seeked: speed changed from ${expectedSpeed} to ${currentSpeed}, restoring`,
|
||||||
|
4
|
||||||
|
);
|
||||||
|
setSpeed(event.target, expectedSpeed, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUserSeek) {
|
||||||
|
isUserSeek = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
target.addEventListener(
|
||||||
|
"loadedmetadata",
|
||||||
|
(this.handleLoadedMetadata = mediaEventAction.bind(this))
|
||||||
|
);
|
||||||
|
target.addEventListener(
|
||||||
|
"loadeddata",
|
||||||
|
(this.handleLoadedData = mediaEventAction.bind(this))
|
||||||
|
);
|
||||||
|
target.addEventListener(
|
||||||
|
"canplay",
|
||||||
|
(this.handleCanPlay = mediaEventAction.bind(this))
|
||||||
|
);
|
||||||
target.addEventListener(
|
target.addEventListener(
|
||||||
"play",
|
"play",
|
||||||
(this.handlePlay = mediaEventAction.bind(this))
|
(this.handlePlay = mediaEventAction.bind(this))
|
||||||
@@ -195,6 +1562,10 @@ function defineVideoController() {
|
|||||||
"pause",
|
"pause",
|
||||||
(this.handlePause = mediaEventAction.bind(this))
|
(this.handlePause = mediaEventAction.bind(this))
|
||||||
);
|
);
|
||||||
|
target.addEventListener(
|
||||||
|
"seeking",
|
||||||
|
(this.handleSeeking = mediaEventAction.bind(this))
|
||||||
|
);
|
||||||
target.addEventListener(
|
target.addEventListener(
|
||||||
"ended",
|
"ended",
|
||||||
(this.handleEnded = mediaEventAction.bind(this))
|
(this.handleEnded = mediaEventAction.bind(this))
|
||||||
@@ -203,6 +1574,7 @@ function defineVideoController() {
|
|||||||
"seeked",
|
"seeked",
|
||||||
(this.handleSeek = mediaEventAction.bind(this))
|
(this.handleSeek = mediaEventAction.bind(this))
|
||||||
);
|
);
|
||||||
|
|
||||||
var srcObserver = new MutationObserver((mutations) => {
|
var srcObserver = new MutationObserver((mutations) => {
|
||||||
mutations.forEach((mutation) => {
|
mutations.forEach((mutation) => {
|
||||||
if (
|
if (
|
||||||
@@ -210,18 +1582,22 @@ function defineVideoController() {
|
|||||||
(mutation.attributeName === "src" ||
|
(mutation.attributeName === "src" ||
|
||||||
mutation.attributeName === "currentSrc")
|
mutation.attributeName === "currentSrc")
|
||||||
) {
|
) {
|
||||||
|
log("mutation of A/V element", 5);
|
||||||
if (this.div) {
|
if (this.div) {
|
||||||
this.stopSubtitleNudge();
|
this.stopSubtitleNudge();
|
||||||
if (!mutation.target.src && !mutation.target.currentSrc) {
|
if (!mutation.target.src && !mutation.target.currentSrc) {
|
||||||
this.div.classList.add("vsc-nosource");
|
this.div.classList.add("vsc-nosource");
|
||||||
} else {
|
} else {
|
||||||
this.div.classList.remove("vsc-nosource");
|
this.div.classList.remove("vsc-nosource");
|
||||||
|
applySourceTransitionPolicy(this.video, true);
|
||||||
if (!mutation.target.paused) this.startSubtitleNudge();
|
if (!mutation.target.paused) this.startSubtitleNudge();
|
||||||
}
|
}
|
||||||
|
updateSubtitleNudgeIndicator(this.video);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
this.srcObserver = srcObserver;
|
||||||
srcObserver.observe(target, { attributeFilter: ["src", "currentSrc"] });
|
srcObserver.observe(target, { attributeFilter: ["src", "currentSrc"] });
|
||||||
if (!target.paused && target.playbackRate !== 1.0)
|
if (!target.paused && target.playbackRate !== 1.0)
|
||||||
this.startSubtitleNudge();
|
this.startSubtitleNudge();
|
||||||
@@ -229,125 +1605,381 @@ function defineVideoController() {
|
|||||||
|
|
||||||
tc.videoController.prototype.remove = function () {
|
tc.videoController.prototype.remove = function () {
|
||||||
this.stopSubtitleNudge();
|
this.stopSubtitleNudge();
|
||||||
|
if (this.youTubeAutoHideObserver) {
|
||||||
|
this.youTubeAutoHideObserver.disconnect();
|
||||||
|
this.youTubeAutoHideObserver = null;
|
||||||
|
}
|
||||||
|
if (this.youTubeAutoHideCleanup) {
|
||||||
|
this.youTubeAutoHideCleanup();
|
||||||
|
this.youTubeAutoHideCleanup = null;
|
||||||
|
}
|
||||||
|
if (this.genericAutoHideCleanup) {
|
||||||
|
this.genericAutoHideCleanup();
|
||||||
|
this.genericAutoHideCleanup = null;
|
||||||
|
}
|
||||||
if (this.div) this.div.remove();
|
if (this.div) this.div.remove();
|
||||||
|
if (this.restoreSpeedTimer) clearTimeout(this.restoreSpeedTimer);
|
||||||
if (this.video) {
|
if (this.video) {
|
||||||
|
this.video.removeEventListener("loadedmetadata", this.handleLoadedMetadata);
|
||||||
|
this.video.removeEventListener("loadeddata", this.handleLoadedData);
|
||||||
|
this.video.removeEventListener("canplay", this.handleCanPlay);
|
||||||
this.video.removeEventListener("play", this.handlePlay);
|
this.video.removeEventListener("play", this.handlePlay);
|
||||||
this.video.removeEventListener("pause", this.handlePause);
|
this.video.removeEventListener("pause", this.handlePause);
|
||||||
|
this.video.removeEventListener("seeking", this.handleSeeking);
|
||||||
this.video.removeEventListener("ended", this.handleEnded);
|
this.video.removeEventListener("ended", this.handleEnded);
|
||||||
this.video.removeEventListener("seeked", this.handleSeek);
|
this.video.removeEventListener("seeked", this.handleSeek);
|
||||||
delete this.video.vsc;
|
delete this.video.vsc;
|
||||||
}
|
}
|
||||||
|
if (this.srcObserver) this.srcObserver.disconnect();
|
||||||
let idx = tc.mediaElements.indexOf(this.video);
|
let idx = tc.mediaElements.indexOf(this.video);
|
||||||
if (idx != -1) tc.mediaElements.splice(idx, 1);
|
if (idx != -1) tc.mediaElements.splice(idx, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
// MODIFIED: Using your debug-enhanced startSubtitleNudge function
|
|
||||||
tc.videoController.prototype.startSubtitleNudge = function () {
|
tc.videoController.prototype.startSubtitleNudge = function () {
|
||||||
console.log("[VSC DEBUG] startSubtitleNudge called");
|
|
||||||
console.log("[VSC DEBUG] location.hostname:", location.hostname);
|
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] enableSubtitleNudge:",
|
|
||||||
tc.settings.enableSubtitleNudge
|
|
||||||
);
|
|
||||||
console.log("[VSC DEBUG] video element:", this.video);
|
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] video src:",
|
|
||||||
this.video ? this.video.src : "no video"
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] video currentSrc:",
|
|
||||||
this.video ? this.video.currentSrc : "no video"
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] video paused:",
|
|
||||||
this.video ? this.video.paused : "no video"
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] video playbackRate:",
|
|
||||||
this.video ? this.video.playbackRate : "no video"
|
|
||||||
);
|
|
||||||
const isYouTube =
|
|
||||||
(this.video &&
|
|
||||||
this.video.currentSrc &&
|
|
||||||
this.video.currentSrc.includes("googlevideo.com")) ||
|
|
||||||
location.hostname.includes("youtube.com");
|
|
||||||
if (!isYouTube) return;
|
|
||||||
if (
|
if (
|
||||||
!tc.settings.enableSubtitleNudge ||
|
!isSubtitleNudgeSupported(this.video) ||
|
||||||
this.nudgeIntervalId !== null ||
|
!isSubtitleNudgeEnabledForVideo(this.video) ||
|
||||||
!this.video
|
this.nudgeAnimationId !== null ||
|
||||||
|
!this.video ||
|
||||||
|
this.video.paused ||
|
||||||
|
this.video.playbackRate === 1.0
|
||||||
) {
|
) {
|
||||||
console.log("[VSC DEBUG] Nudge blocked - reasons:", {
|
|
||||||
enableSubtitleNudge: tc.settings.enableSubtitleNudge,
|
|
||||||
nudgeIntervalId: this.nudgeIntervalId,
|
|
||||||
hasVideo: !!this.video
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.video.paused || this.video.playbackRate === 1.0) {
|
|
||||||
console.log("[VSC DEBUG] Nudge stopped - video paused or 1.0x speed");
|
// Store the target speed so we can always revert to it
|
||||||
this.stopSubtitleNudge();
|
this.targetSpeed = this.video.playbackRate;
|
||||||
return;
|
|
||||||
}
|
const performNudge = () => {
|
||||||
console.log("[VSC DEBUG] Starting nudge interval");
|
// Check if we should stop
|
||||||
log(`Nudge: Starting interval: ${tc.settings.subtitleNudgeInterval}ms.`, 5);
|
if (!this.video || this.video.paused || this.video.playbackRate === 1.0) {
|
||||||
this.nudgeIntervalId = setInterval(() => {
|
|
||||||
if (
|
|
||||||
!this.video ||
|
|
||||||
this.video.paused ||
|
|
||||||
this.video.playbackRate === 1.0 ||
|
|
||||||
tc.isNudging
|
|
||||||
) {
|
|
||||||
this.stopSubtitleNudge();
|
this.stopSubtitleNudge();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const currentRate = this.video.playbackRate;
|
|
||||||
const nudgeAmount = tc.settings.subtitleNudgeAmount;
|
// CRITICAL: Don't nudge if tab is hidden - prevents speed drift
|
||||||
|
if (document.hidden) {
|
||||||
|
if (!this.visibilityResumeHandler && this.video && this.video.ownerDocument) {
|
||||||
|
this.visibilityResumeHandler = () => {
|
||||||
|
if (this.video.ownerDocument.hidden) return;
|
||||||
|
this.video.ownerDocument.removeEventListener(
|
||||||
|
"visibilitychange",
|
||||||
|
this.visibilityResumeHandler,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
this.visibilityResumeHandler = null;
|
||||||
|
this.startSubtitleNudge();
|
||||||
|
};
|
||||||
|
this.video.ownerDocument.addEventListener(
|
||||||
|
"visibilitychange",
|
||||||
|
this.visibilityResumeHandler,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.nudgeAnimationId = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set flag to prevent ratechange listener from interfering
|
||||||
tc.isNudging = true;
|
tc.isNudging = true;
|
||||||
this.video.playbackRate = currentRate + nudgeAmount;
|
suppressNextNudgeRateChanges(this, 2);
|
||||||
requestAnimationFrame(() => {
|
|
||||||
if (
|
// Cache values to avoid repeated property access
|
||||||
this.video &&
|
const targetSpeed = this.targetSpeed;
|
||||||
Math.abs(this.video.playbackRate - (currentRate + nudgeAmount)) <
|
const nudgeAmount = tc.settings.subtitleNudgeAmount;
|
||||||
nudgeAmount * 1.5
|
|
||||||
) {
|
// Apply nudge from the stored target speed (not current rate)
|
||||||
this.video.playbackRate = currentRate;
|
this.video.playbackRate = targetSpeed + nudgeAmount;
|
||||||
|
|
||||||
|
// Revert synchronously after a microtask to ensure it happens immediately
|
||||||
|
Promise.resolve().then(() => {
|
||||||
|
if (this.video && targetSpeed) {
|
||||||
|
this.video.playbackRate = targetSpeed;
|
||||||
}
|
}
|
||||||
tc.isNudging = false;
|
tc.isNudging = false;
|
||||||
});
|
});
|
||||||
}, tc.settings.subtitleNudgeInterval);
|
|
||||||
|
// Schedule next nudge
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
|
if (this.visibilityResumeHandler && this.video && this.video.ownerDocument) {
|
||||||
|
this.video.ownerDocument.removeEventListener(
|
||||||
|
"visibilitychange",
|
||||||
|
this.visibilityResumeHandler,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
this.visibilityResumeHandler = null;
|
||||||
|
}
|
||||||
|
// Clear the animation state, but PRESERVE targetSpeed so getDesiredSpeed
|
||||||
|
// doesn't lose the user's intended speed if the site hijacks it.
|
||||||
|
};
|
||||||
|
|
||||||
|
tc.videoController.prototype.performImmediateNudge = function () {
|
||||||
|
if (
|
||||||
|
!isSubtitleNudgeSupported(this.video) ||
|
||||||
|
!isSubtitleNudgeEnabledForVideo(this.video) ||
|
||||||
|
!this.video ||
|
||||||
|
this.video.paused ||
|
||||||
|
this.video.playbackRate === 1.0 ||
|
||||||
|
document.hidden
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetRate = this.targetSpeed || this.video.playbackRate;
|
||||||
|
const nudgeAmount = tc.settings.subtitleNudgeAmount;
|
||||||
|
|
||||||
|
tc.isNudging = true;
|
||||||
|
suppressNextNudgeRateChanges(this, 2);
|
||||||
|
this.video.playbackRate = targetRate + nudgeAmount;
|
||||||
|
|
||||||
|
// Revert synchronously via microtask
|
||||||
|
Promise.resolve().then(() => {
|
||||||
|
if (this.video) {
|
||||||
|
this.video.playbackRate = targetRate;
|
||||||
|
}
|
||||||
|
tc.isNudging = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
log(`Immediate nudge performed at rate ${targetRate.toFixed(2)}`, 5);
|
||||||
|
};
|
||||||
|
|
||||||
|
tc.videoController.prototype.setupYouTubeAutoHide = function (wrapper) {
|
||||||
|
if (!wrapper || !isOnYouTube()) return;
|
||||||
|
|
||||||
|
const video = this.video;
|
||||||
|
const ytPlayer = video.closest(".html5-video-player");
|
||||||
|
if (!ytPlayer) {
|
||||||
|
log("YouTube player not found for auto-hide setup", 4);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const syncControllerVisibility = () => {
|
||||||
|
// YouTube adds ytp-autohide class to the player when controls should be hidden
|
||||||
|
// We mirror this class state to enable CSS-based hiding
|
||||||
|
// The vsc-hidden class (from V key) takes precedence via CSS specificity
|
||||||
|
if (ytPlayer.classList.contains("ytp-autohide")) {
|
||||||
|
wrapper.classList.add("ytp-autohide");
|
||||||
|
|
||||||
|
// Immediately end any temporary "vsc-show" state to hide with YouTube
|
||||||
|
// UNLESS it was forced by a shortcut (vsc-forced-show)
|
||||||
|
if (!wrapper.classList.contains("vsc-forced-show")) {
|
||||||
|
wrapper.classList.remove("vsc-show");
|
||||||
|
if (wrapper.showTimeOut) {
|
||||||
|
clearTimeout(wrapper.showTimeOut);
|
||||||
|
wrapper.showTimeOut = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log("YouTube controls hidden, hiding controller", 5);
|
||||||
|
} else {
|
||||||
|
wrapper.classList.remove("ytp-autohide");
|
||||||
|
log("YouTube controls visible, showing controller", 5);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initial sync
|
||||||
|
syncControllerVisibility();
|
||||||
|
|
||||||
|
// Observe YouTube player class changes
|
||||||
|
this.youTubeAutoHideObserver = new MutationObserver((mutations) => {
|
||||||
|
mutations.forEach((mutation) => {
|
||||||
|
if (mutation.type === "attributes" && mutation.attributeName === "class") {
|
||||||
|
syncControllerVisibility();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.youTubeAutoHideObserver.observe(ytPlayer, {
|
||||||
|
attributes: true,
|
||||||
|
attributeFilter: ["class"]
|
||||||
|
});
|
||||||
|
|
||||||
|
log("YouTube auto-hide observer setup complete", 4);
|
||||||
|
|
||||||
|
// Also reveal on hover/activity independently of YouTube's own controls
|
||||||
|
// for immediate responsiveness, UNLESS Speeder is actually toggled hidden (vsc-hidden)
|
||||||
|
const resetTimer = () => {
|
||||||
|
showController(wrapper, tc.settings.hideWithControlsTimer * 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
const activityEvents = ["mousemove", "mousedown", "touchstart"];
|
||||||
|
activityEvents.forEach((type) => {
|
||||||
|
video.addEventListener(type, resetTimer, { passive: true });
|
||||||
|
wrapper.addEventListener(type, resetTimer, { passive: true });
|
||||||
|
ytPlayer.addEventListener(type, resetTimer, { passive: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Store a cleanup function
|
||||||
|
this.youTubeAutoHideCleanup = () => {
|
||||||
|
activityEvents.forEach((type) => {
|
||||||
|
video.removeEventListener(type, resetTimer);
|
||||||
|
wrapper.removeEventListener(type, resetTimer);
|
||||||
|
ytPlayer.removeEventListener(type, resetTimer);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
tc.videoController.prototype.setupGenericAutoHide = function (wrapper) {
|
||||||
|
if (!wrapper) return;
|
||||||
|
|
||||||
|
const video = this.video;
|
||||||
|
let timer = null;
|
||||||
|
|
||||||
|
const resetTimer = () => {
|
||||||
|
wrapper.classList.remove("vsc-idle-hidden");
|
||||||
|
showController(wrapper, tc.settings.hideWithControlsTimer * 1000);
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
timer = setTimeout(() => {
|
||||||
|
// Only hide if the video is not paused
|
||||||
|
// (Many players keep controls visible while paused)
|
||||||
|
// However, the user said "Reveal on every mouse and keyboard input"
|
||||||
|
// and "auto-hidden after timespan".
|
||||||
|
// We'll follow the timer strictly.
|
||||||
|
wrapper.classList.add("vsc-idle-hidden");
|
||||||
|
log("Generic hide: controller hidden due to inactivity", 5);
|
||||||
|
}, tc.settings.hideWithControlsTimer * 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initial show/timer
|
||||||
|
resetTimer();
|
||||||
|
|
||||||
|
// The wrapper covers the player area on most sites due to inject.css styles,
|
||||||
|
// but we listen on both the video and the wrapper for maximum coverage.
|
||||||
|
const activityEvents = ["mousemove", "mousedown", "keydown", "touchstart"];
|
||||||
|
const parentEl = video.parentElement;
|
||||||
|
activityEvents.forEach((type) => {
|
||||||
|
video.addEventListener(type, resetTimer, { passive: true });
|
||||||
|
wrapper.addEventListener(type, resetTimer, { passive: true });
|
||||||
|
if (parentEl) {
|
||||||
|
parentEl.addEventListener(type, resetTimer, { passive: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Also reset timer on play/pause events to ensure sync when player state changes
|
||||||
|
video.addEventListener("play", resetTimer, { passive: true });
|
||||||
|
video.addEventListener("pause", resetTimer, { passive: true });
|
||||||
|
|
||||||
|
// Store a cleanup function
|
||||||
|
this.genericAutoHideCleanup = () => {
|
||||||
|
if (timer) clearTimeout(timer);
|
||||||
|
activityEvents.forEach((type) => {
|
||||||
|
video.removeEventListener(type, resetTimer);
|
||||||
|
wrapper.removeEventListener(type, resetTimer);
|
||||||
|
if (parentEl) {
|
||||||
|
parentEl.removeEventListener(type, resetTimer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
video.removeEventListener("play", resetTimer);
|
||||||
|
video.removeEventListener("pause", resetTimer);
|
||||||
|
};
|
||||||
|
|
||||||
|
log(`Generic auto-hide setup complete with ${tc.settings.hideWithControlsTimer}s timer`, 4);
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
var top = Math.max(this.video.offsetTop, 0) + "px",
|
|
||||||
left = Math.max(this.video.offsetLeft, 0) + "px";
|
|
||||||
var wrapper = doc.createElement("div");
|
var wrapper = doc.createElement("div");
|
||||||
wrapper.classList.add("vsc-controller");
|
wrapper.classList.add("vsc-controller");
|
||||||
if (!this.video.src && !this.video.currentSrc)
|
if (!this.video.src && !this.video.currentSrc)
|
||||||
wrapper.classList.add("vsc-nosource");
|
wrapper.classList.add("vsc-nosource");
|
||||||
if (tc.settings.startHidden) wrapper.classList.add("vsc-hidden");
|
if (tc.settings.startHidden) wrapper.classList.add("vsc-hidden");
|
||||||
|
// Use lower z-index for non-YouTube sites to avoid overlapping modals
|
||||||
|
if (!isOnYouTube()) wrapper.classList.add("vsc-non-youtube");
|
||||||
var shadow = wrapper.attachShadow({ mode: "open" });
|
var shadow = wrapper.attachShadow({ mode: "open" });
|
||||||
shadow.innerHTML = `<style> @import "${chrome.runtime.getURL("shadow.css")}"; </style><div id="controller" style="top:${top}; left:${left}; opacity:${tc.settings.controllerOpacity}"><span data-action="drag" class="draggable">${speed}</span><span id="controls"><button data-action="rewind" class="rw">«</button><button data-action="slower">−</button><button data-action="faster">+</button><button data-action="advance" class="rw">»</button><button data-action="display" class="hideButton">×</button></span></div>`;
|
var shadowStylesheet = doc.createElement("link");
|
||||||
this.speedIndicator = shadow.querySelector(".draggable");
|
shadowStylesheet.rel = "stylesheet";
|
||||||
shadow.querySelector(".draggable").addEventListener(
|
shadowStylesheet.href = chrome.runtime.getURL("shadow.css");
|
||||||
|
shadow.appendChild(shadowStylesheet);
|
||||||
|
|
||||||
|
var controller = doc.createElement("div");
|
||||||
|
controller.id = "controller";
|
||||||
|
controller.style.opacity = String(tc.settings.controllerOpacity);
|
||||||
|
this.controllerLocation = applyControllerLocationToElement(
|
||||||
|
controller,
|
||||||
|
this.controllerLocation
|
||||||
|
);
|
||||||
|
|
||||||
|
var dragHandle = doc.createElement("span");
|
||||||
|
dragHandle.dataset.action = "drag";
|
||||||
|
dragHandle.className = "draggable";
|
||||||
|
dragHandle.textContent = speed;
|
||||||
|
|
||||||
|
var controls = doc.createElement("span");
|
||||||
|
controls.id = "controls";
|
||||||
|
|
||||||
|
var buttonConfig = Array.isArray(tc.settings.controllerButtons)
|
||||||
|
? tc.settings.controllerButtons
|
||||||
|
: ["rewind", "slower", "faster", "advance", "display"];
|
||||||
|
|
||||||
|
var subtitleNudgeIndicator = null;
|
||||||
|
|
||||||
|
buttonConfig.forEach(function (btnId) {
|
||||||
|
if (btnId === "nudge") {
|
||||||
|
subtitleNudgeIndicator = doc.createElement("span");
|
||||||
|
subtitleNudgeIndicator.id = "nudge-indicator";
|
||||||
|
subtitleNudgeIndicator.setAttribute("role", "button");
|
||||||
|
subtitleNudgeIndicator.setAttribute("aria-live", "polite");
|
||||||
|
subtitleNudgeIndicator.setAttribute("tabindex", "0");
|
||||||
|
controls.appendChild(subtitleNudgeIndicator);
|
||||||
|
} else {
|
||||||
|
var def = controllerButtonDefs[btnId];
|
||||||
|
if (def) {
|
||||||
|
controls.appendChild(
|
||||||
|
createControllerButton(doc, btnId, def.label, def.className)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var nudgeFlashIndicator = doc.createElement("span");
|
||||||
|
nudgeFlashIndicator.id = "nudge-flash-indicator";
|
||||||
|
nudgeFlashIndicator.setAttribute("aria-hidden", "true");
|
||||||
|
|
||||||
|
controller.appendChild(dragHandle);
|
||||||
|
controller.appendChild(controls);
|
||||||
|
/* Flash sits after #controls so it never inserts space between speed and buttons. */
|
||||||
|
controller.appendChild(nudgeFlashIndicator);
|
||||||
|
shadow.appendChild(controller);
|
||||||
|
|
||||||
|
this.speedIndicator = dragHandle;
|
||||||
|
this.subtitleNudgeIndicator = subtitleNudgeIndicator;
|
||||||
|
this.nudgeFlashIndicator = nudgeFlashIndicator;
|
||||||
|
this.resetButtonEl =
|
||||||
|
shadow.querySelector('button[data-action="reset"]') || null;
|
||||||
|
this.resetToggleArmed = false;
|
||||||
|
if (subtitleNudgeIndicator) {
|
||||||
|
updateSubtitleNudgeIndicator(this.video);
|
||||||
|
}
|
||||||
|
function blurAfterPointerTap(target, e) {
|
||||||
|
if (!target || typeof target.blur !== "function") return;
|
||||||
|
var pt = e.pointerType;
|
||||||
|
if (pt === "mouse" || pt === "touch" || (!pt && e.detail > 0)) {
|
||||||
|
requestAnimationFrame(function () {
|
||||||
|
target.blur();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dragHandle.addEventListener(
|
||||||
"mousedown",
|
"mousedown",
|
||||||
(e) => {
|
(e) => {
|
||||||
runAction(
|
var dragAction = dragHandle.dataset.action;
|
||||||
e.target.dataset["action"],
|
runAction(dragAction, getKeyBindings(dragAction, "value"), e);
|
||||||
getKeyBindings(e.target.dataset["action"], "value"),
|
|
||||||
e,
|
|
||||||
this.video
|
|
||||||
);
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
@@ -356,52 +1988,102 @@ function defineVideoController() {
|
|||||||
button.addEventListener(
|
button.addEventListener(
|
||||||
"click",
|
"click",
|
||||||
(e) => {
|
(e) => {
|
||||||
runAction(
|
var action = button.dataset.action;
|
||||||
e.target.dataset["action"],
|
runAction(action, getKeyBindings(action), e);
|
||||||
getKeyBindings(e.target.dataset["action"]),
|
blurAfterPointerTap(button, e);
|
||||||
e,
|
|
||||||
this.video
|
|
||||||
);
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
shadow
|
if (subtitleNudgeIndicator) {
|
||||||
.querySelector("#controller")
|
subtitleNudgeIndicator.addEventListener(
|
||||||
.addEventListener("click", (e) => e.stopPropagation(), false);
|
"click",
|
||||||
shadow
|
(e) => {
|
||||||
.querySelector("#controller")
|
var video = this.video;
|
||||||
.addEventListener("mousedown", (e) => e.stopPropagation(), false);
|
if (video) {
|
||||||
|
var newState = !isSubtitleNudgeEnabledForVideo(video);
|
||||||
|
setSubtitleNudgeEnabledForVideo(video, newState);
|
||||||
|
}
|
||||||
|
blurAfterPointerTap(subtitleNudgeIndicator, e);
|
||||||
|
e.stopPropagation();
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
controller.addEventListener("click", (e) => e.stopPropagation(), false);
|
||||||
|
controller.addEventListener("mousedown", (e) => e.stopPropagation(), false);
|
||||||
|
|
||||||
|
// Setup auto-hide observers if enabled
|
||||||
|
if (tc.settings.hideWithControls) {
|
||||||
|
if (isOnYouTube()) {
|
||||||
|
this.setupYouTubeAutoHide(wrapper);
|
||||||
|
} else {
|
||||||
|
this.setupGenericAutoHide(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var fragment = doc.createDocumentFragment();
|
var fragment = doc.createDocumentFragment();
|
||||||
fragment.appendChild(wrapper);
|
fragment.appendChild(wrapper);
|
||||||
const parentEl = this.parent || this.video.parentElement;
|
const parentEl = this.parent || this.video.parentElement;
|
||||||
|
|
||||||
|
log(`Inserting controller: parentEl=${!!parentEl}, parentNode=${!!parentEl?.parentNode}, hostname=${location.hostname}`, 4);
|
||||||
|
|
||||||
if (!parentEl || !parentEl.parentNode) {
|
if (!parentEl || !parentEl.parentNode) {
|
||||||
|
log("No suitable parent found, appending to body", 4);
|
||||||
doc.body.appendChild(fragment);
|
doc.body.appendChild(fragment);
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
switch (true) {
|
|
||||||
case location.hostname == "www.amazon.com":
|
try {
|
||||||
case location.hostname == "www.reddit.com":
|
switch (true) {
|
||||||
case /hbogo\./.test(location.hostname):
|
case location.hostname == "www.amazon.com":
|
||||||
parentEl.parentElement.insertBefore(fragment, parentEl);
|
case location.hostname == "www.reddit.com":
|
||||||
break;
|
case /hbogo\./.test(location.hostname):
|
||||||
case location.hostname == "www.facebook.com":
|
log("Using parentElement.parentElement insertion", 5);
|
||||||
let p =
|
parentEl.parentElement.insertBefore(fragment, parentEl);
|
||||||
parentEl.parentElement.parentElement.parentElement.parentElement
|
break;
|
||||||
.parentElement.parentElement.parentElement;
|
case location.hostname == "www.facebook.com":
|
||||||
if (p && p.firstChild) p.insertBefore(fragment, p.firstChild);
|
log("Using Facebook-specific insertion", 5);
|
||||||
else parentEl.insertBefore(fragment, parentEl.firstChild);
|
let p =
|
||||||
break;
|
parentEl.parentElement.parentElement.parentElement.parentElement
|
||||||
case location.hostname == "tv.apple.com":
|
.parentElement.parentElement.parentElement;
|
||||||
const r = parentEl.getRootNode();
|
if (p && p.firstChild) p.insertBefore(fragment, p.firstChild);
|
||||||
const s = r && r.querySelector ? r.querySelector(".scrim") : null;
|
else parentEl.insertBefore(fragment, parentEl.firstChild);
|
||||||
if (s) s.prepend(fragment);
|
break;
|
||||||
else parentEl.insertBefore(fragment, pEl.firstChild);
|
case location.hostname == "tv.apple.com":
|
||||||
break;
|
log("Using Apple TV-specific insertion", 5);
|
||||||
default:
|
const r = parentEl.getRootNode();
|
||||||
parentEl.insertBefore(fragment, parentEl.firstChild);
|
const s = r && r.querySelector ? r.querySelector(".scrim") : null;
|
||||||
|
if (s) s.prepend(fragment);
|
||||||
|
else parentEl.insertBefore(fragment, parentEl.firstChild);
|
||||||
|
break;
|
||||||
|
case location.hostname == "www.youtube.com":
|
||||||
|
case location.hostname == "m.youtube.com":
|
||||||
|
case location.hostname == "music.youtube.com":
|
||||||
|
// YouTube's player DOM has .html5-video-container (video's parent) as a
|
||||||
|
// low layer with overlay siblings (.ytp-player-content, etc.) on top that
|
||||||
|
// intercept mouse events. Insert into .html5-video-player (the player
|
||||||
|
// root) so the controller sits above all overlay layers.
|
||||||
|
log("Using YouTube-specific insertion", 5);
|
||||||
|
var ytPlayer = parentEl.closest(".html5-video-player");
|
||||||
|
if (ytPlayer) {
|
||||||
|
ytPlayer.insertBefore(fragment, ytPlayer.firstChild);
|
||||||
|
} else {
|
||||||
|
parentEl.insertBefore(fragment, parentEl.firstChild);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log("Using default insertion method", 5);
|
||||||
|
parentEl.insertBefore(fragment, parentEl.firstChild);
|
||||||
|
}
|
||||||
|
log("Controller successfully inserted into DOM", 4);
|
||||||
|
} catch (error) {
|
||||||
|
log(`Error inserting controller: ${error.message}`, 2);
|
||||||
|
// Fallback to body insertion
|
||||||
|
doc.body.appendChild(fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -410,92 +2092,264 @@ function escapeStringRegExp(str) {
|
|||||||
const m = /[|\\{}()[\]^$+*?.]/g;
|
const m = /[|\\{}()[\]^$+*?.]/g;
|
||||||
return str.replace(m, "\\$&");
|
return str.replace(m, "\\$&");
|
||||||
}
|
}
|
||||||
function isBlacklisted() {
|
function applySiteRuleOverrides() {
|
||||||
let b = false;
|
resetSettingsFromSiteRuleBase();
|
||||||
const l = tc.settings.blacklist ? tc.settings.blacklist.split("\n") : [];
|
|
||||||
l.forEach((m) => {
|
if (!Array.isArray(tc.settings.siteRules) || tc.settings.siteRules.length === 0) {
|
||||||
if (b) return;
|
return false;
|
||||||
m = m.replace(regStrip, "");
|
}
|
||||||
if (m.length == 0) return;
|
|
||||||
let r;
|
var currentUrl = location.href;
|
||||||
if (m.startsWith("/") && m.lastIndexOf("/") > 0) {
|
var matchedRule = null;
|
||||||
|
|
||||||
|
for (var i = 0; i < tc.settings.siteRules.length; i++) {
|
||||||
|
var rule = tc.settings.siteRules[i];
|
||||||
|
var pattern = rule.pattern;
|
||||||
|
if (!pattern || pattern.length === 0) continue;
|
||||||
|
|
||||||
|
var regex;
|
||||||
|
if (pattern.startsWith("/") && pattern.lastIndexOf("/") > 0) {
|
||||||
try {
|
try {
|
||||||
const ls = m.lastIndexOf("/");
|
var lastSlash = pattern.lastIndexOf("/");
|
||||||
r = new RegExp(m.substring(1, ls), m.substring(ls + 1));
|
regex = new RegExp(
|
||||||
|
pattern.substring(1, lastSlash),
|
||||||
|
pattern.substring(lastSlash + 1)
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(`Invalid regex: ${m}. ${e.message}`, 2);
|
log(`Invalid site rule regex: ${pattern}. ${e.message}`, 2);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
} else r = new RegExp(escapeStringRegExp(m));
|
} else {
|
||||||
if (r && r.test(location.href)) b = true;
|
regex = new RegExp(escapeStringRegExp(pattern));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regex && regex.test(currentUrl)) {
|
||||||
|
matchedRule = rule;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!matchedRule) return false;
|
||||||
|
|
||||||
|
tc.activeSiteRule = matchedRule;
|
||||||
|
log(`Matched site rule: ${matchedRule.pattern}`, 4);
|
||||||
|
|
||||||
|
// Check if extension should be enabled/disabled on this site
|
||||||
|
if (matchedRule.enabled === false) {
|
||||||
|
log(`Extension disabled for site: ${currentUrl}`, 4);
|
||||||
|
return true;
|
||||||
|
} else if (matchedRule.disableExtension === true) {
|
||||||
|
// Handle old format
|
||||||
|
log(`Extension disabled (legacy) for site: ${currentUrl}`, 4);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override general settings with site-specific overrides
|
||||||
|
const siteSettings = [
|
||||||
|
"startHidden",
|
||||||
|
"hideWithControls",
|
||||||
|
"hideWithControlsTimer",
|
||||||
|
"controllerLocation",
|
||||||
|
"rememberSpeed",
|
||||||
|
"forceLastSavedSpeed",
|
||||||
|
"audioBoolean",
|
||||||
|
"controllerOpacity",
|
||||||
|
"controllerMarginTop",
|
||||||
|
"controllerMarginBottom",
|
||||||
|
"enableSubtitleNudge",
|
||||||
|
"subtitleNudgeInterval"
|
||||||
|
];
|
||||||
|
|
||||||
|
siteSettings.forEach((key) => {
|
||||||
|
if (matchedRule[key] !== undefined) {
|
||||||
|
log(`Overriding ${key} for site: ${matchedRule[key]}`, 4);
|
||||||
|
tc.settings[key] = matchedRule[key];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (b) log(`Page ${location.href} blacklisted.`, 4);
|
|
||||||
return b;
|
[
|
||||||
}
|
"controllerMarginTop",
|
||||||
var coolDown = false;
|
"controllerMarginBottom"
|
||||||
function refreshCoolDown() {
|
].forEach(function (key) {
|
||||||
if (coolDown) clearTimeout(coolDown);
|
tc.settings[key] = normalizeControllerMarginPx(tc.settings[key], 0);
|
||||||
coolDown = setTimeout(function () {
|
});
|
||||||
coolDown = false;
|
|
||||||
}, 1000);
|
if (Array.isArray(matchedRule.controllerButtons)) {
|
||||||
|
log(`Overriding controllerButtons for site`, 4);
|
||||||
|
tc.settings.controllerButtons = matchedRule.controllerButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override key bindings with site-specific shortcuts
|
||||||
|
if (Array.isArray(matchedRule.shortcuts) && matchedRule.shortcuts.length > 0) {
|
||||||
|
var overriddenActions = new Set();
|
||||||
|
matchedRule.shortcuts.forEach((shortcut) => {
|
||||||
|
overriddenActions.add(shortcut.action);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Keep global bindings that aren't overridden, add site-specific ones
|
||||||
|
tc.settings.keyBindings = tc.settings.keyBindings
|
||||||
|
.filter((binding) => !overriddenActions.has(binding.action))
|
||||||
|
.concat(
|
||||||
|
matchedRule.shortcuts.map((shortcut) =>
|
||||||
|
normalizeStoredBinding(shortcut)
|
||||||
|
).filter(Boolean)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupListener() {
|
/** Apply current tc.settings controller layout/opacity to every attached controller (after site rules). */
|
||||||
if (document.vscRateListenerAttached) return;
|
function refreshAllControllerGeometry() {
|
||||||
function updateSpeedFromEvent(video, fromUserInput = false) {
|
tc.mediaElements.forEach(function (video) {
|
||||||
if (!video.vsc || !video.vsc.speedIndicator) return;
|
if (!video || !video.vsc) return;
|
||||||
var speed = Number(video.playbackRate.toFixed(2));
|
applyControllerLocation(video.vsc, tc.settings.controllerLocation);
|
||||||
video.vsc.speedIndicator.textContent = speed.toFixed(2);
|
var controllerEl = getControllerElement(video.vsc);
|
||||||
tc.settings.speeds[video.currentSrc || "unknown_src"] = speed;
|
if (controllerEl) {
|
||||||
tc.settings.lastSpeed = speed;
|
controllerEl.style.opacity = String(tc.settings.controllerOpacity);
|
||||||
chrome.storage.sync.set({ lastSpeed: speed }, () => {});
|
|
||||||
if (fromUserInput) {
|
|
||||||
runAction("blink", getKeyBindings("blink", "value") || 1000, null, video);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Re-match site rules for current URL and refresh controller position/opacity on every video. */
|
||||||
|
function reapplySiteRulesAndControllerGeometry() {
|
||||||
|
var siteDisabled = applySiteRuleOverrides();
|
||||||
|
if (!tc.settings.enabled || siteDisabled) return;
|
||||||
|
refreshAllControllerGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldPreserveDesiredSpeed(video, speed) {
|
||||||
|
if (!video || !video.vsc) return false;
|
||||||
|
var desiredSpeed = getDesiredSpeed(video);
|
||||||
|
if (!isValidSpeed(desiredSpeed) || Math.abs(speed - desiredSpeed) <= 0.01) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
video.paused === true ||
|
||||||
|
(typeof video.vsc.speedRestoreUntil === "number" &&
|
||||||
|
video.vsc.speedRestoreUntil > Date.now())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupListener(root) {
|
||||||
|
root = root || document;
|
||||||
|
if (root.vscRateListenerAttached) return;
|
||||||
|
function updateSpeedFromEvent(video, skipResetDisarm) {
|
||||||
|
if (!video.vsc || !video.vsc.speedIndicator) return;
|
||||||
|
if (!skipResetDisarm) {
|
||||||
|
video.vsc.resetToggleArmed = false;
|
||||||
|
}
|
||||||
|
var speed = video.playbackRate; // Preserve full precision (e.g. 0.0625)
|
||||||
|
video.vsc.speedIndicator.textContent = speed.toFixed(2);
|
||||||
|
video.vsc.targetSpeed = speed;
|
||||||
|
video.vsc.targetSpeedSourceKey = getVideoSourceKey(video);
|
||||||
|
var sourceKey = getVideoSourceKey(video);
|
||||||
|
if (sourceKey !== "unknown_src") {
|
||||||
|
tc.settings.speeds[sourceKey] = speed;
|
||||||
|
}
|
||||||
|
tc.settings.lastSpeed = speed;
|
||||||
|
schedulePersistLastSpeed(speed);
|
||||||
if (video.vsc) {
|
if (video.vsc) {
|
||||||
if (speed === 1.0 || video.paused) video.vsc.stopSubtitleNudge();
|
if (speed === 1.0 || video.paused) video.vsc.stopSubtitleNudge();
|
||||||
else video.vsc.startSubtitleNudge();
|
else video.vsc.startSubtitleNudge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.addEventListener(
|
root.addEventListener(
|
||||||
"ratechange",
|
"ratechange",
|
||||||
function (event) {
|
function (event) {
|
||||||
if (tc.isNudging) return;
|
if (tc.isNudging) return;
|
||||||
if (coolDown) {
|
|
||||||
event.stopImmediatePropagation();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var video = event.target;
|
var video = event.target;
|
||||||
if (!video || typeof video.playbackRate === "undefined" || !video.vsc)
|
if (!video || typeof video.playbackRate === "undefined" || !video.vsc)
|
||||||
return;
|
return;
|
||||||
|
if (shouldIgnoreSuppressedRateChange(video)) return;
|
||||||
if (tc.settings.forceLastSavedSpeed) {
|
if (tc.settings.forceLastSavedSpeed) {
|
||||||
if (event.detail && event.detail.origin === "videoSpeed") {
|
if (event.detail && event.detail.origin === "videoSpeed") {
|
||||||
video.playbackRate = event.detail.speed;
|
video.playbackRate = event.detail.speed;
|
||||||
updateSpeedFromEvent(video, event.detail.fromUserInput === true);
|
updateSpeedFromEvent(video, true);
|
||||||
} else {
|
} else {
|
||||||
video.playbackRate = tc.settings.lastSpeed;
|
video.playbackRate = sanitizeSpeed(tc.settings.lastSpeed, 1.0);
|
||||||
}
|
}
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
} else {
|
} else {
|
||||||
updateSpeedFromEvent(video, video.vscIsDirectlySettingRate === true);
|
var currentSpeed = video.playbackRate; // Preserve full precision (e.g. 0.0625)
|
||||||
if (video.vscIsDirectlySettingRate)
|
var desiredSpeed = getDesiredSpeed(video);
|
||||||
delete video.vscIsDirectlySettingRate;
|
var pendingRateChange = takePendingRateChange(video, currentSpeed);
|
||||||
|
|
||||||
|
if (pendingRateChange) {
|
||||||
|
updateSpeedFromEvent(video, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldPreserveDesiredSpeed(video, currentSpeed)) {
|
||||||
|
log(
|
||||||
|
`Ignoring external rate change to ${currentSpeed.toFixed(4)} while preserving ${desiredSpeed.toFixed(4)}`,
|
||||||
|
4
|
||||||
|
);
|
||||||
|
video.vsc.resetToggleArmed = false;
|
||||||
|
video.vsc.speedIndicator.textContent = desiredSpeed.toFixed(2);
|
||||||
|
scheduleSpeedRestore(video, desiredSpeed, "pause/play or seek");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSpeedFromEvent(video);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
document.vscRateListenerAttached = true;
|
root.vscRateListenerAttached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var vscInitializedDocuments = new Set();
|
var vscInitializedDocuments = new Set();
|
||||||
function initializeWhenReady(doc) {
|
function clearPendingInitialization(doc) {
|
||||||
if (vscInitializedDocuments.has(doc) || !doc.body) return;
|
if (!doc || !doc.vscPendingInitializeHandler) return;
|
||||||
if (doc.readyState === "complete") {
|
|
||||||
initializeNow(doc);
|
var handler = doc.vscPendingInitializeHandler;
|
||||||
|
doc.removeEventListener("DOMContentLoaded", handler);
|
||||||
|
doc.removeEventListener("readystatechange", handler);
|
||||||
|
|
||||||
|
if (doc.defaultView) {
|
||||||
|
doc.defaultView.removeEventListener("load", handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete doc.vscPendingInitializeHandler;
|
||||||
|
doc.vscPendingForceReinit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tryInitializeDocument(doc, forceReinit) {
|
||||||
|
if (!doc) return false;
|
||||||
|
if ((!forceReinit && vscInitializedDocuments.has(doc)) || !doc.body) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeNow(doc, forceReinit);
|
||||||
|
clearPendingInitialization(doc);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeWhenReady(doc, forceReinit = false) {
|
||||||
|
if (!doc) return;
|
||||||
|
doc.vscPendingForceReinit = doc.vscPendingForceReinit === true || forceReinit;
|
||||||
|
|
||||||
|
if (tryInitializeDocument(doc, doc.vscPendingForceReinit)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.vscPendingInitializeHandler) return;
|
||||||
|
|
||||||
|
var pendingInitializeHandler = function () {
|
||||||
|
tryInitializeDocument(doc, doc.vscPendingForceReinit === true);
|
||||||
|
};
|
||||||
|
|
||||||
|
doc.vscPendingInitializeHandler = pendingInitializeHandler;
|
||||||
|
doc.addEventListener("DOMContentLoaded", pendingInitializeHandler);
|
||||||
|
doc.addEventListener("readystatechange", pendingInitializeHandler);
|
||||||
|
|
||||||
|
if (doc.defaultView) {
|
||||||
|
doc.defaultView.addEventListener("load", pendingInitializeHandler);
|
||||||
|
doc.defaultView.setTimeout(pendingInitializeHandler, 0);
|
||||||
} else {
|
} else {
|
||||||
doc.addEventListener("DOMContentLoaded", () => initializeNow(doc), {
|
setTimeout(pendingInitializeHandler, 0);
|
||||||
once: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function inIframe() {
|
function inIframe() {
|
||||||
@@ -505,47 +2359,18 @@ function inIframe() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getShadow(parent) {
|
|
||||||
let r = [];
|
|
||||||
function gC(p) {
|
|
||||||
if (p.firstElementChild) {
|
|
||||||
var c = p.firstElementChild;
|
|
||||||
do {
|
|
||||||
r.push(c);
|
|
||||||
gC(c);
|
|
||||||
if (c.shadowRoot) r.push(...getShadow(c.shadowRoot));
|
|
||||||
c = c.nextElementSibling;
|
|
||||||
} while (c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gC(parent);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MODIFIED: Replaced with your debug-enhanced initializeNow
|
function attachKeydownListeners(doc) {
|
||||||
function initializeNow(doc) {
|
var docs = [doc];
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] initializeNow called for:",
|
|
||||||
doc.location ? doc.location.hostname : "unknown doc"
|
|
||||||
);
|
|
||||||
if (vscInitializedDocuments.has(doc) || !doc.body) return;
|
|
||||||
if (!tc.settings.enabled) return;
|
|
||||||
if (!doc.body.classList.contains("vsc-initialized"))
|
|
||||||
doc.body.classList.add("vsc-initialized");
|
|
||||||
if (typeof tc.videoController === "undefined") defineVideoController();
|
|
||||||
setupListener();
|
|
||||||
|
|
||||||
// Re-inserting original keydown listener logic from your codebase
|
|
||||||
var docs = Array(doc);
|
|
||||||
try {
|
try {
|
||||||
if (inIframe()) docs.push(window.top.document);
|
if (inIframe() && window.top.document !== doc) docs.push(window.top.document);
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
docs.forEach(function (d) {
|
|
||||||
if (d.vscKeydownListenerAttached) return; // Prevent duplicate listeners
|
docs.forEach(function (keyDoc) {
|
||||||
d.addEventListener(
|
if (keyDoc.vscKeydownListenerAttached) return;
|
||||||
|
keyDoc.addEventListener(
|
||||||
"keydown",
|
"keydown",
|
||||||
function (event) {
|
function (event) {
|
||||||
var keyCode = event.keyCode;
|
|
||||||
if (
|
if (
|
||||||
!event.getModifierState ||
|
!event.getModifierState ||
|
||||||
event.getModifierState("Alt") ||
|
event.getModifierState("Alt") ||
|
||||||
@@ -554,149 +2379,224 @@ function initializeNow(doc) {
|
|||||||
event.getModifierState("Meta") ||
|
event.getModifierState("Meta") ||
|
||||||
event.getModifierState("Hyper") ||
|
event.getModifierState("Hyper") ||
|
||||||
event.getModifierState("OS")
|
event.getModifierState("OS")
|
||||||
)
|
) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
event.target.nodeName === "INPUT" ||
|
event.target.nodeName === "INPUT" ||
|
||||||
event.target.nodeName === "TEXTAREA" ||
|
event.target.nodeName === "TEXTAREA" ||
|
||||||
event.target.isContentEditable
|
event.target.isContentEditable
|
||||||
)
|
) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tc.mediaElements.length) return;
|
if (!tc.mediaElements.length) return;
|
||||||
var item = tc.settings.keyBindings.find((item) => item.key === keyCode);
|
|
||||||
|
var item = tc.settings.keyBindings.find(function (binding) {
|
||||||
|
return matchesKeyBinding(binding, event);
|
||||||
|
});
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
runAction(item.action, item.value, event);
|
runAction(item.action, item.value, event);
|
||||||
if (item.force === "true") {
|
|
||||||
event.preventDefault();
|
// Always prevent default and stop propagation for Speeder shortcuts
|
||||||
event.stopPropagation();
|
// to prevent the website (e.g. YouTube) from reacting to these keys.
|
||||||
}
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
d.vscKeydownListenerAttached = true;
|
keyDoc.vscKeydownListenerAttached = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachMutationObserver(root) {
|
||||||
|
if (root.vscMutationObserverAttached) return;
|
||||||
|
|
||||||
|
var pendingMutations = [];
|
||||||
|
var mutationProcessingScheduled = false;
|
||||||
|
var observer = new MutationObserver(function (mutations) {
|
||||||
|
pendingMutations.push(...mutations);
|
||||||
|
if (mutationProcessingScheduled) return;
|
||||||
|
|
||||||
|
mutationProcessingScheduled = true;
|
||||||
|
requestIdle(
|
||||||
|
function () {
|
||||||
|
var mutationsToProcess = pendingMutations.splice(0);
|
||||||
|
mutationProcessingScheduled = false;
|
||||||
|
|
||||||
|
mutationsToProcess.forEach(function (mutation) {
|
||||||
|
if (mutation.type === "childList") {
|
||||||
|
mutation.addedNodes.forEach(function (node) {
|
||||||
|
// Skip text nodes, comments, etc. — only elements can contain media
|
||||||
|
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
||||||
|
scanNodeForMedia(node, node.parentNode || mutation.target, true);
|
||||||
|
});
|
||||||
|
mutation.removedNodes.forEach(function (node) {
|
||||||
|
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
||||||
|
scanNodeForMedia(node, node.parentNode || mutation.target, false);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mutation.type !== "attributes") return;
|
||||||
|
|
||||||
|
var target = mutation.target;
|
||||||
|
if (
|
||||||
|
isMediaElement(target) &&
|
||||||
|
(mutation.attributeName === "src" ||
|
||||||
|
mutation.attributeName === "currentSrc")
|
||||||
|
) {
|
||||||
|
ensureController(target, target.parentElement || target.parentNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
mutation.attributeName === "aria-hidden" &&
|
||||||
|
target.attributes["aria-hidden"] &&
|
||||||
|
target.attributes["aria-hidden"].value === "false"
|
||||||
|
) {
|
||||||
|
scanNodeForMedia(
|
||||||
|
target,
|
||||||
|
target.parentNode || root.host || mutation.target,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{ timeout: 1000 }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Original MutationObserver logic
|
observer.observe(root, {
|
||||||
if (!doc.vscMutationObserverAttached) {
|
attributeFilter: ["aria-hidden", "src", "currentSrc"],
|
||||||
const observer = new MutationObserver(function (mutations) {
|
childList: true,
|
||||||
requestIdleCallback(
|
subtree: true,
|
||||||
(_) => {
|
attributes: true
|
||||||
mutations.forEach(function (mutation) {
|
});
|
||||||
switch (mutation.type) {
|
|
||||||
case "childList":
|
root.vscMutationObserverAttached = true;
|
||||||
mutation.addedNodes.forEach(function (node) {
|
}
|
||||||
if (typeof node === "function") return;
|
|
||||||
checkForVideo(node, node.parentNode || mutation.target, true);
|
function attachMediaDetectionListeners(root) {
|
||||||
});
|
if (root.vscMediaEventListenersAttached) return;
|
||||||
mutation.removedNodes.forEach(function (node) {
|
|
||||||
if (typeof node === "function") return;
|
var handleDetectedMedia = function (event) {
|
||||||
checkForVideo(
|
var target = event.target;
|
||||||
node,
|
if (!isMediaElement(target)) return;
|
||||||
node.parentNode || mutation.target,
|
ensureController(target, target.parentElement || target.parentNode);
|
||||||
false
|
};
|
||||||
);
|
|
||||||
});
|
[
|
||||||
break;
|
"loadstart",
|
||||||
case "attributes":
|
"loadeddata",
|
||||||
if (
|
"loadedmetadata",
|
||||||
mutation.target.attributes["aria-hidden"] &&
|
"canplay",
|
||||||
mutation.target.attributes["aria-hidden"].value == "false"
|
"playing",
|
||||||
) {
|
"play"
|
||||||
var flattenedNodes = getShadow(document.body);
|
].forEach(function (eventName) {
|
||||||
var node = flattenedNodes.filter(
|
root.addEventListener(eventName, handleDetectedMedia, true);
|
||||||
(x) => x.tagName == "VIDEO"
|
});
|
||||||
)[0];
|
root.vscMediaEventListenersAttached = true;
|
||||||
if (node) {
|
}
|
||||||
if (node.vsc) node.vsc.remove();
|
|
||||||
checkForVideo(
|
function attachIframeListeners(doc) {
|
||||||
node,
|
Array.from(doc.getElementsByTagName("iframe")).forEach(function (frame) {
|
||||||
node.parentNode || mutation.target,
|
if (!frame.vscLoadListenerAttached) {
|
||||||
true
|
frame.addEventListener("load", function () {
|
||||||
);
|
try {
|
||||||
}
|
if (frame.contentDocument) {
|
||||||
}
|
initializeWhenReady(frame.contentDocument, true);
|
||||||
break;
|
}
|
||||||
}
|
} catch (e) { }
|
||||||
});
|
});
|
||||||
},
|
frame.vscLoadListenerAttached = true;
|
||||||
{ timeout: 1000 }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
function checkForVideo(node, parent, added) {
|
|
||||||
if (!added && document.body.contains(node)) return;
|
|
||||||
if (
|
|
||||||
node.nodeName === "VIDEO" ||
|
|
||||||
(node.nodeName === "AUDIO" && tc.settings.audioBoolean)
|
|
||||||
) {
|
|
||||||
if (added) {
|
|
||||||
if (!node.vsc) node.vsc = new tc.videoController(node, parent);
|
|
||||||
} else {
|
|
||||||
if (node.vsc) node.vsc.remove();
|
|
||||||
}
|
|
||||||
} else if (node.children != undefined) {
|
|
||||||
for (var i = 0; i < node.children.length; i++) {
|
|
||||||
const child = node.children[i];
|
|
||||||
checkForVideo(child, child.parentNode || parent, added);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
observer.observe(doc, {
|
|
||||||
attributeFilter: ["aria-hidden"],
|
try {
|
||||||
childList: true,
|
if (frame.contentDocument) {
|
||||||
subtree: true
|
initializeWhenReady(frame.contentDocument);
|
||||||
});
|
}
|
||||||
doc.vscMutationObserverAttached = true;
|
} catch (e) { }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachNavigationListeners() {
|
||||||
|
if (window.vscNavigationListenersAttached) return;
|
||||||
|
|
||||||
|
var scheduleRescan = function () {
|
||||||
|
clearTimeout(window.vscNavigationRescanTimer);
|
||||||
|
window.vscNavigationRescanTimer = setTimeout(function () {
|
||||||
|
initializeWhenReady(document, true);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
["pushState", "replaceState"].forEach(function (method) {
|
||||||
|
if (typeof history[method] !== "function") return;
|
||||||
|
var original = history[method];
|
||||||
|
history[method] = function () {
|
||||||
|
var result = original.apply(this, arguments);
|
||||||
|
scheduleRescan();
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener("popstate", scheduleRescan);
|
||||||
|
window.addEventListener("hashchange", scheduleRescan);
|
||||||
|
/* YouTube often navigates without a history API call the extension can see first */
|
||||||
|
if (typeof document !== "undefined" && isOnYouTube()) {
|
||||||
|
document.addEventListener("yt-navigate-finish", scheduleRescan);
|
||||||
|
}
|
||||||
|
window.vscNavigationListenersAttached = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeNow(doc, forceReinit = false) {
|
||||||
|
if ((!forceReinit && vscInitializedDocuments.has(doc)) || !doc.body) return;
|
||||||
|
|
||||||
|
var siteDisabled = applySiteRuleOverrides();
|
||||||
|
if (!tc.settings.enabled || siteDisabled) return;
|
||||||
|
|
||||||
|
if (!doc.body.classList.contains("vsc-initialized")) {
|
||||||
|
doc.body.classList.add("vsc-initialized");
|
||||||
|
}
|
||||||
|
if (typeof tc.videoController === "undefined") defineVideoController();
|
||||||
|
attachKeydownListeners(doc);
|
||||||
|
attachNavigationListeners();
|
||||||
|
observeRoot(doc);
|
||||||
|
|
||||||
|
if (forceReinit) {
|
||||||
|
log("Force re-initialization requested", 4);
|
||||||
|
refreshAllControllerGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
const q = tc.settings.audioBoolean ? "video,audio" : "video";
|
|
||||||
const foundVideos = doc.querySelectorAll(q);
|
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] Found videos:",
|
|
||||||
foundVideos.length,
|
|
||||||
"in doc:",
|
|
||||||
doc.location ? doc.location.hostname : "unknown"
|
|
||||||
);
|
|
||||||
foundVideos.forEach((v) => {
|
|
||||||
if (!v.vsc) new tc.videoController(v, v.parentElement);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Your enhanced iframe handling
|
|
||||||
Array.from(doc.getElementsByTagName("iframe")).forEach((f) => {
|
|
||||||
console.log("[VSC DEBUG] Found iframe:", f.src);
|
|
||||||
if (f.vscLoadListenerAttached) return; // Prevent attaching multiple load listeners
|
|
||||||
f.addEventListener("load", () => {
|
|
||||||
console.log("[VSC DEBUG] Iframe loaded, attempting to access");
|
|
||||||
try {
|
|
||||||
if (f.contentDocument) {
|
|
||||||
initializeWhenReady(f.contentDocument);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log(
|
|
||||||
"[VSC DEBUG] Still cannot access iframe after load:",
|
|
||||||
e.message
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
f.vscLoadListenerAttached = true;
|
|
||||||
try {
|
|
||||||
if (f.contentDocument) {
|
|
||||||
initializeWhenReady(f.contentDocument);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log("[VSC DEBUG] Error accessing iframe immediately:", e.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
vscInitializedDocuments.add(doc);
|
vscInitializedDocuments.add(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODIFIED: setSpeed now takes isUserKeyPress for blink logic
|
function setSpeed(
|
||||||
function setSpeed(video, speed, isInitialCall = false, isUserKeyPress = false) {
|
video,
|
||||||
|
speed,
|
||||||
|
isInitialCall = false,
|
||||||
|
isUserKeyPress = false,
|
||||||
|
fromResetSpeedToggle = false
|
||||||
|
) {
|
||||||
const numericSpeed = Number(speed);
|
const numericSpeed = Number(speed);
|
||||||
if (isNaN(numericSpeed) || numericSpeed <= 0 || numericSpeed > 16) return;
|
|
||||||
|
if (!isValidSpeed(numericSpeed)) {
|
||||||
|
log(
|
||||||
|
`Invalid speed rejected: ${speed}, must be between ${MIN_SPEED} and ${MAX_SPEED}`,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!video || !video.vsc || !video.vsc.speedIndicator) return;
|
if (!video || !video.vsc || !video.vsc.speedIndicator) return;
|
||||||
|
|
||||||
|
if (isUserKeyPress && !fromResetSpeedToggle) {
|
||||||
|
video.vsc.resetToggleArmed = false;
|
||||||
|
}
|
||||||
|
|
||||||
log(
|
log(
|
||||||
`setSpeed: Target ${numericSpeed.toFixed(2)}. Initial: ${isInitialCall}. UserKeyPress: ${isUserKeyPress}`,
|
`setSpeed: Target ${numericSpeed.toFixed(2)}. Initial: ${isInitialCall}. UserKeyPress: ${isUserKeyPress}`,
|
||||||
4
|
4
|
||||||
@@ -704,10 +2604,17 @@ function setSpeed(video, speed, isInitialCall = false, isUserKeyPress = false) {
|
|||||||
tc.settings.lastSpeed = numericSpeed;
|
tc.settings.lastSpeed = numericSpeed;
|
||||||
video.vsc.speedIndicator.textContent = numericSpeed.toFixed(2);
|
video.vsc.speedIndicator.textContent = numericSpeed.toFixed(2);
|
||||||
|
|
||||||
|
// Update the target speed for nudge so it knows what to revert to
|
||||||
|
video.vsc.targetSpeed = numericSpeed;
|
||||||
|
video.vsc.targetSpeedSourceKey = getVideoSourceKey(video);
|
||||||
|
|
||||||
if (isUserKeyPress && !isInitialCall && video.vsc && video.vsc.div) {
|
if (isUserKeyPress && !isInitialCall && video.vsc && video.vsc.div) {
|
||||||
runAction("blink", null, null, video); // Pass video to blink
|
runAction("blink", 1000, null, video); // Pass video to blink
|
||||||
|
extendSpeedRestoreWindow(video); // Protect against immediate site-driven resets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try YouTube's native speed API first — keeps subtitles in sync without nudge
|
||||||
|
var usedNativeSpeed = false;
|
||||||
if (tc.settings.forceLastSavedSpeed) {
|
if (tc.settings.forceLastSavedSpeed) {
|
||||||
video.dispatchEvent(
|
video.dispatchEvent(
|
||||||
new CustomEvent("ratechange", {
|
new CustomEvent("ratechange", {
|
||||||
@@ -720,24 +2627,34 @@ function setSpeed(video, speed, isInitialCall = false, isUserKeyPress = false) {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (Math.abs(video.playbackRate - numericSpeed) > 0.001) {
|
if (Math.abs(video.playbackRate - numericSpeed) > 0.001) {
|
||||||
if (isUserKeyPress && !isInitialCall) {
|
rememberPendingRateChange(video, numericSpeed);
|
||||||
video.vscIsDirectlySettingRate = true; // Set flag for ratechange listener
|
usedNativeSpeed = tryYouTubeNativeSpeed(video, numericSpeed);
|
||||||
|
if (!usedNativeSpeed) {
|
||||||
|
video.playbackRate = numericSpeed;
|
||||||
}
|
}
|
||||||
video.playbackRate = numericSpeed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isInitialCall) refreshCoolDown();
|
|
||||||
if (video.vsc) {
|
if (video.vsc) {
|
||||||
if (numericSpeed === 1.0 || video.paused) video.vsc.stopSubtitleNudge();
|
if (numericSpeed === 1.0 || video.paused) {
|
||||||
else video.vsc.startSubtitleNudge();
|
video.vsc.stopSubtitleNudge();
|
||||||
|
} else if (usedNativeSpeed) {
|
||||||
|
// YouTube's native API handles subtitle sync — no nudge needed
|
||||||
|
video.vsc.stopSubtitleNudge();
|
||||||
|
} else {
|
||||||
|
video.vsc.startSubtitleNudge();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODIFIED: runAction is now context-aware and calls the new simpler resetSpeed
|
|
||||||
function runAction(action, value, e) {
|
function runAction(action, value, e) {
|
||||||
log("runAction Begin", 5);
|
log("runAction Begin", 5);
|
||||||
var mediaTagsToProcess;
|
var mediaTagsToProcess;
|
||||||
if (e && e.target && e.target.getRootNode) {
|
const specificVideo = arguments[3] || null;
|
||||||
|
var subtitleNudgeToggleValue = null;
|
||||||
|
|
||||||
|
if (specificVideo) {
|
||||||
|
mediaTagsToProcess = [specificVideo];
|
||||||
|
} else if (e && e.target && e.target.getRootNode) {
|
||||||
// Event-driven action
|
// Event-driven action
|
||||||
const docContext = e.target.ownerDocument || document;
|
const docContext = e.target.ownerDocument || document;
|
||||||
mediaTagsToProcess = tc.mediaElements.filter(
|
mediaTagsToProcess = tc.mediaElements.filter(
|
||||||
@@ -746,20 +2663,28 @@ function runAction(action, value, e) {
|
|||||||
const targetController = e.target.getRootNode().host;
|
const targetController = e.target.getRootNode().host;
|
||||||
if (targetController) {
|
if (targetController) {
|
||||||
// If it's a click on a controller, only use that one video
|
// If it's a click on a controller, only use that one video
|
||||||
const specificVideo = tc.mediaElements.find(
|
const videoFromController = tc.mediaElements.find(
|
||||||
(v) => v.vsc && v.vsc.div === targetController
|
(v) => v.vsc && v.vsc.div === targetController
|
||||||
);
|
);
|
||||||
if (specificVideo) mediaTagsToProcess = [specificVideo];
|
if (videoFromController) mediaTagsToProcess = [videoFromController];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No event context (e.g., internal blink call) or a passed specificVideo
|
mediaTagsToProcess = tc.mediaElements;
|
||||||
const specificVideo = arguments[3] || null; // The optional 4th argument
|
}
|
||||||
if (specificVideo) mediaTagsToProcess = [specificVideo];
|
if (action === "settings") {
|
||||||
else mediaTagsToProcess = tc.mediaElements;
|
chrome.runtime.sendMessage({ action: "openOptions" });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (mediaTagsToProcess.length === 0 && action !== "display") return;
|
if (mediaTagsToProcess.length === 0 && action !== "display") return;
|
||||||
|
|
||||||
|
if (action === "toggleSubtitleNudge" && mediaTagsToProcess.length > 0) {
|
||||||
|
subtitleNudgeToggleValue = !isSubtitleNudgeEnabledForVideo(
|
||||||
|
mediaTagsToProcess[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
mediaTagsToProcess.forEach(function (v) {
|
mediaTagsToProcess.forEach(function (v) {
|
||||||
|
if (!v.vsc) return; // Don't process videos without a controller
|
||||||
var controller = v.vsc.div;
|
var controller = v.vsc.div;
|
||||||
const userDrivenActionsThatShowController = [
|
const userDrivenActionsThatShowController = [
|
||||||
"rewind",
|
"rewind",
|
||||||
@@ -768,71 +2693,113 @@ function runAction(action, value, e) {
|
|||||||
"slower",
|
"slower",
|
||||||
"reset",
|
"reset",
|
||||||
"fast",
|
"fast",
|
||||||
|
"move",
|
||||||
"pause",
|
"pause",
|
||||||
"muted",
|
"muted",
|
||||||
"mark",
|
"mark",
|
||||||
"jump",
|
"jump",
|
||||||
"drag"
|
"drag",
|
||||||
|
"nudge",
|
||||||
|
"toggleSubtitleNudge",
|
||||||
|
"display"
|
||||||
];
|
];
|
||||||
if (userDrivenActionsThatShowController.includes(action)) {
|
if (userDrivenActionsThatShowController.includes(action) && action !== "display") {
|
||||||
showController(controller);
|
showController(controller, 2000, true);
|
||||||
}
|
}
|
||||||
if (v.classList.contains("vsc-cancelled")) return;
|
if (v.classList.contains("vsc-cancelled")) return;
|
||||||
const numValue = parseFloat(value);
|
const numValue = parseFloat(value);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "rewind":
|
case "rewind":
|
||||||
|
isUserSeek = true;
|
||||||
|
extendSpeedRestoreWindow(v);
|
||||||
v.currentTime -= numValue;
|
v.currentTime -= numValue;
|
||||||
break;
|
break;
|
||||||
case "advance":
|
case "advance":
|
||||||
|
isUserSeek = true;
|
||||||
|
extendSpeedRestoreWindow(v);
|
||||||
v.currentTime += numValue;
|
v.currentTime += numValue;
|
||||||
break;
|
break;
|
||||||
case "faster":
|
case "faster":
|
||||||
setSpeed(
|
var fasterStep = numValue;
|
||||||
v,
|
// Use grid-snapping: always move to the next multiple of fasterStep
|
||||||
Math.min(
|
// Add a tiny epsilon (1% of step) to jump clear of the current point
|
||||||
(v.playbackRate < 0.07 ? 0.07 : v.playbackRate) + numValue,
|
var newFasterSpeed = Math.ceil((v.playbackRate + (fasterStep * 0.01)) / fasterStep) * fasterStep;
|
||||||
16
|
// Clean up JS floating point math (e.g. 0.30000000000000004 -> 0.30)
|
||||||
),
|
newFasterSpeed = Math.round(newFasterSpeed * 1000) / 1000;
|
||||||
false,
|
setSpeed(v, Math.min(newFasterSpeed, MAX_SPEED), false, true);
|
||||||
true
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case "slower":
|
case "slower":
|
||||||
setSpeed(v, Math.max(v.playbackRate - numValue, 0.07), false, true);
|
var slowerStep = numValue;
|
||||||
|
// Use grid-snapping: always move to the previous multiple of slowerStep
|
||||||
|
// Subtract a tiny epsilon (1% of step) to jump clear of the current point
|
||||||
|
var newSlowerSpeed = Math.floor((v.playbackRate - (slowerStep * 0.01)) / slowerStep) * slowerStep;
|
||||||
|
// Clean up JS floating point math
|
||||||
|
newSlowerSpeed = Math.round(newSlowerSpeed * 1000) / 1000;
|
||||||
|
setSpeed(v, Math.max(newSlowerSpeed, MIN_SPEED), false, true);
|
||||||
break;
|
break;
|
||||||
case "reset":
|
case "reset":
|
||||||
resetSpeed(v, 1.0);
|
resetSpeed(v, 1.0, false); // Use enhanced resetSpeed
|
||||||
break; // Use new simpler resetSpeed
|
break;
|
||||||
case "fast":
|
case "fast":
|
||||||
resetSpeed(v, numValue, true);
|
var preferredSpeed = numValue;
|
||||||
break; // Use new simpler resetSpeed
|
// Apply site-specific preferred speed override if available
|
||||||
|
if (tc.activeSiteRule && typeof tc.activeSiteRule.preferredSpeed === "number") {
|
||||||
|
preferredSpeed = tc.activeSiteRule.preferredSpeed;
|
||||||
|
}
|
||||||
|
resetSpeed(v, preferredSpeed, true);
|
||||||
|
break;
|
||||||
case "display":
|
case "display":
|
||||||
controller.classList.add("vsc-manual");
|
if (controller.classList.contains("vsc-hidden")) {
|
||||||
controller.classList.toggle("vsc-hidden");
|
controller.classList.remove("vsc-hidden");
|
||||||
|
showController(controller, 2000, true);
|
||||||
|
} else {
|
||||||
|
controller.classList.add("vsc-hidden");
|
||||||
|
// Clear any show state when explicitly hiding
|
||||||
|
controller.classList.remove("vsc-show");
|
||||||
|
controller.classList.remove("vsc-forced-show");
|
||||||
|
if (controller.showTimeOut) {
|
||||||
|
clearTimeout(controller.showTimeOut);
|
||||||
|
controller.showTimeOut = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "blink":
|
case "blink":
|
||||||
|
log(`Blink action: controller hidden=${controller.classList.contains("vsc-hidden")}, timeout=${controller.blinkTimeOut !== undefined}, duration=${numValue}`, 5);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
controller.classList.contains("vsc-hidden") ||
|
controller.classList.contains("vsc-hidden") ||
|
||||||
controller.blinkTimeOut !== undefined
|
controller.blinkTimeOut !== undefined
|
||||||
) {
|
) {
|
||||||
clearTimeout(controller.blinkTimeOut);
|
var restoreHidden =
|
||||||
|
controller.restoreHiddenAfterBlink === true ||
|
||||||
|
controller.classList.contains("vsc-hidden");
|
||||||
|
|
||||||
|
if (controller.blinkTimeOut !== undefined) {
|
||||||
|
clearTimeout(controller.blinkTimeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.restoreHiddenAfterBlink = restoreHidden;
|
||||||
controller.classList.remove("vsc-hidden");
|
controller.classList.remove("vsc-hidden");
|
||||||
|
log(`Controller shown, setting timeout for ${numValue || 1000}ms`, 5);
|
||||||
|
|
||||||
controller.blinkTimeOut = setTimeout(() => {
|
controller.blinkTimeOut = setTimeout(() => {
|
||||||
if (
|
if (controller.restoreHiddenAfterBlink === true) {
|
||||||
!(
|
|
||||||
controller.classList.contains("vsc-manual") &&
|
|
||||||
!controller.classList.contains("vsc-hidden")
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
controller.classList.add("vsc-hidden");
|
controller.classList.add("vsc-hidden");
|
||||||
|
log("Controller auto-hidden after blink timeout", 5);
|
||||||
|
} else {
|
||||||
|
log("Controller kept visible", 5);
|
||||||
}
|
}
|
||||||
|
controller.restoreHiddenAfterBlink = false;
|
||||||
controller.blinkTimeOut = undefined;
|
controller.blinkTimeOut = undefined;
|
||||||
}, value || 1000);
|
}, numValue || 1000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "drag":
|
case "drag":
|
||||||
if (e) handleDrag(v, e);
|
if (e) handleDrag(v, e);
|
||||||
break;
|
break;
|
||||||
|
case "move":
|
||||||
|
cycleControllerLocation(v);
|
||||||
|
break;
|
||||||
case "pause":
|
case "pause":
|
||||||
pause(v);
|
pause(v);
|
||||||
break;
|
break;
|
||||||
@@ -845,6 +2812,15 @@ function runAction(action, value, e) {
|
|||||||
case "jump":
|
case "jump":
|
||||||
jumpToMark(v);
|
jumpToMark(v);
|
||||||
break;
|
break;
|
||||||
|
case "toggleSubtitleNudge":
|
||||||
|
setSubtitleNudgeEnabledForVideo(v, subtitleNudgeToggleValue);
|
||||||
|
break;
|
||||||
|
case "nudge":
|
||||||
|
setSubtitleNudgeEnabledForVideo(
|
||||||
|
v,
|
||||||
|
!isSubtitleNudgeEnabledForVideo(v)
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
log("runAction End", 5);
|
log("runAction End", 5);
|
||||||
@@ -855,22 +2831,40 @@ function pause(v) {
|
|||||||
else v.pause();
|
else v.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODIFIED: Replaced with new, simpler resetSpeed function
|
|
||||||
function resetSpeed(v, target, isFastKey = false) {
|
function resetSpeed(v, target, isFastKey = false) {
|
||||||
const fastSpeed = getKeyBindings("fast", "value") || 1.8;
|
const videoId = getVideoSourceKey(v);
|
||||||
|
const currentSpeed = v.playbackRate;
|
||||||
|
|
||||||
if (isFastKey) {
|
if (isFastKey) {
|
||||||
// Called by 'fast' action
|
// G key: Toggle between current speed and preferred speed (e.g., 1.8)
|
||||||
if (Math.abs(v.playbackRate - target) < 0.01) {
|
const preferredSpeed = target;
|
||||||
setSpeed(v, 1.0, false, true); // Toggle to 1.0
|
const lastToggle = lastToggleSpeed[videoId] || currentSpeed;
|
||||||
|
|
||||||
|
if (Math.abs(currentSpeed - preferredSpeed) < 0.01) {
|
||||||
|
// Currently at preferred speed, toggle to the last speed
|
||||||
|
setSpeed(v, lastToggle, false, true);
|
||||||
} else {
|
} else {
|
||||||
setSpeed(v, target, false, true); // Set to preferred speed
|
// Not at preferred speed, save current as toggle speed and go to preferred
|
||||||
|
lastToggleSpeed[videoId] = currentSpeed;
|
||||||
|
setSpeed(v, preferredSpeed, false, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Called by 'reset' action
|
// R key: Toggle between current speed and 1.0
|
||||||
if (Math.abs(v.playbackRate - 1.0) < 0.01) {
|
const resetSpeedValue = 1.0;
|
||||||
setSpeed(v, fastSpeed, false, true); // Toggle to fast speed
|
const lastToggle = lastToggleSpeed[videoId] || currentSpeed;
|
||||||
|
|
||||||
|
if (Math.abs(currentSpeed - resetSpeedValue) < 0.01) {
|
||||||
|
// Currently at 1.0, toggle to the last speed (or 1.8 if no history)
|
||||||
|
const speedToRestore =
|
||||||
|
Math.abs(lastToggle - 1.0) < 0.01
|
||||||
|
? getKeyBindings("fast") || 1.8
|
||||||
|
: lastToggle;
|
||||||
|
setSpeed(v, speedToRestore, false, true, true);
|
||||||
} else {
|
} else {
|
||||||
setSpeed(v, 1.0, false, true); // Set to 1.0
|
// Not at 1.0, save current as toggle speed and go to 1.0
|
||||||
|
lastToggleSpeed[videoId] = currentSpeed;
|
||||||
|
v.vsc.resetToggleArmed = true;
|
||||||
|
setSpeed(v, resetSpeedValue, false, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -882,12 +2876,15 @@ function setMark(v) {
|
|||||||
v.vsc.mark = v.currentTime;
|
v.vsc.mark = v.currentTime;
|
||||||
}
|
}
|
||||||
function jumpToMark(v) {
|
function jumpToMark(v) {
|
||||||
if (v.vsc && typeof v.vsc.mark === "number") v.currentTime = v.vsc.mark;
|
if (v.vsc && typeof v.vsc.mark === "number") {
|
||||||
|
extendSpeedRestoreWindow(v);
|
||||||
|
v.currentTime = v.vsc.mark;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function handleDrag(video, e) {
|
function handleDrag(video, e) {
|
||||||
/* ... Same original logic ... */
|
|
||||||
const c = video.vsc.div;
|
const c = video.vsc.div;
|
||||||
const sC = c.shadowRoot.querySelector("#controller");
|
const sC = convertControllerToManualPosition(video.vsc);
|
||||||
|
if (!sC) return;
|
||||||
var pE = c.parentElement;
|
var pE = c.parentElement;
|
||||||
while (
|
while (
|
||||||
pE.parentNode &&
|
pE.parentNode &&
|
||||||
@@ -900,9 +2897,16 @@ function handleDrag(video, e) {
|
|||||||
const iXY = [e.clientX, e.clientY],
|
const iXY = [e.clientX, e.clientY],
|
||||||
iCXY = [parseInt(sC.style.left), parseInt(sC.style.top)];
|
iCXY = [parseInt(sC.style.left), parseInt(sC.style.top)];
|
||||||
const sD = (e) => {
|
const sD = (e) => {
|
||||||
let s = sC.style;
|
sC.style.setProperty(
|
||||||
s.left = iCXY[0] + e.clientX - iXY[0] + "px";
|
"left",
|
||||||
s.top = iCXY[1] + e.clientY - iXY[1] + "px";
|
iCXY[0] + e.clientX - iXY[0] + "px",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
|
sC.style.setProperty(
|
||||||
|
"top",
|
||||||
|
iCXY[1] + e.clientY - iXY[1] + "px",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
};
|
};
|
||||||
const eD = () => {
|
const eD = () => {
|
||||||
pE.removeEventListener("mousemove", sD);
|
pE.removeEventListener("mousemove", sD);
|
||||||
@@ -915,14 +2919,39 @@ function handleDrag(video, e) {
|
|||||||
pE.addEventListener("mouseleave", eD);
|
pE.addEventListener("mouseleave", eD);
|
||||||
pE.addEventListener("mousemove", sD);
|
pE.addEventListener("mousemove", sD);
|
||||||
}
|
}
|
||||||
var timer = null;
|
function showController(controller, duration = 2000, forced = false) {
|
||||||
function showController(controller) {
|
|
||||||
/* ... Same original logic ... */
|
|
||||||
if (!controller || typeof controller.classList === "undefined") return;
|
if (!controller || typeof controller.classList === "undefined") return;
|
||||||
controller.classList.add("vcs-show");
|
var restoreHidden =
|
||||||
if (timer) clearTimeout(timer);
|
controller.restoreHiddenAfterShow === true ||
|
||||||
timer = setTimeout(function () {
|
controller.classList.contains("vsc-hidden");
|
||||||
|
|
||||||
|
controller.restoreHiddenAfterShow = restoreHidden;
|
||||||
|
controller.classList.remove("vsc-hidden");
|
||||||
|
controller.classList.add("vsc-show");
|
||||||
|
if (forced) {
|
||||||
|
controller.classList.add("vsc-forced-show");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controller.showTimeOut !== undefined) {
|
||||||
|
clearTimeout(controller.showTimeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.showTimeOut = setTimeout(function () {
|
||||||
controller.classList.remove("vsc-show");
|
controller.classList.remove("vsc-show");
|
||||||
timer = false;
|
controller.classList.remove("vsc-forced-show");
|
||||||
}, 2000);
|
if (controller.restoreHiddenAfterShow === true) {
|
||||||
|
controller.classList.add("vsc-hidden");
|
||||||
|
}
|
||||||
|
controller.restoreHiddenAfterShow = false;
|
||||||
|
controller.showTimeOut = undefined;
|
||||||
|
}, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add global listener to handle fullscreen transitions and adjust controller positions
|
||||||
|
document.addEventListener("fullscreenchange", () => {
|
||||||
|
tc.mediaElements.forEach((video) => {
|
||||||
|
if (video.vsc) {
|
||||||
|
applyControllerLocation(video.vsc, video.vsc.controllerLocation);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
/**
|
||||||
|
* Lucide static icons via jsDelivr (same registry as lucide.dev).
|
||||||
|
* ISC License — https://lucide.dev
|
||||||
|
*/
|
||||||
|
var LUCIDE_STATIC_VERSION = "1.7.0";
|
||||||
|
var LUCIDE_CDN_BASE =
|
||||||
|
"https://cdn.jsdelivr.net/npm/lucide-static@" +
|
||||||
|
LUCIDE_STATIC_VERSION;
|
||||||
|
|
||||||
|
var LUCIDE_TAGS_CACHE_KEY = "lucideTagsCacheV1";
|
||||||
|
var LUCIDE_TAGS_MAX_AGE_MS = 1000 * 60 * 60 * 24 * 7; /* 7 days */
|
||||||
|
|
||||||
|
function lucideIconSvgUrl(slug) {
|
||||||
|
if (!slug || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/i.test(slug)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return LUCIDE_CDN_BASE + "/icons/" + slug.toLowerCase() + ".svg";
|
||||||
|
}
|
||||||
|
|
||||||
|
function lucideTagsJsonUrl() {
|
||||||
|
return LUCIDE_CDN_BASE + "/tags.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Collapse whitespace for smaller storage. */
|
||||||
|
function lucideMinifySvg(s) {
|
||||||
|
return String(s).replace(/\s+/g, " ").trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function sanitizeLucideSvg(svgText) {
|
||||||
|
if (!svgText || typeof svgText !== "string") return null;
|
||||||
|
var t = String(svgText).replace(/\0/g, "").trim();
|
||||||
|
if (!/<svg[\s>]/i.test(t)) return null;
|
||||||
|
var doc = new DOMParser().parseFromString(t, "image/svg+xml");
|
||||||
|
if (doc.querySelector("parsererror")) return null;
|
||||||
|
var svg = vscSanitizeSvgTree(doc.querySelector("svg"));
|
||||||
|
if (!svg) return null;
|
||||||
|
svg.removeAttribute("width");
|
||||||
|
svg.removeAttribute("height");
|
||||||
|
svg.setAttribute("width", "100%");
|
||||||
|
svg.setAttribute("height", "100%");
|
||||||
|
svg.setAttribute("aria-hidden", "true");
|
||||||
|
return lucideMinifySvg(svg.outerHTML);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchLucideSvg(slug) {
|
||||||
|
var url = lucideIconSvgUrl(slug);
|
||||||
|
if (!url) {
|
||||||
|
return Promise.reject(new Error("Invalid icon name"));
|
||||||
|
}
|
||||||
|
return fetch(url, { cache: "force-cache" }).then(function (r) {
|
||||||
|
if (!r.ok) {
|
||||||
|
throw new Error("Icon not found: " + slug);
|
||||||
|
}
|
||||||
|
return r.text();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchAndCacheLucideTags(chromeLocal, resolve, reject) {
|
||||||
|
fetch(lucideTagsJsonUrl(), { cache: "force-cache" })
|
||||||
|
.then(function (r) {
|
||||||
|
if (!r.ok) throw new Error("tags.json HTTP " + r.status);
|
||||||
|
return r.json();
|
||||||
|
})
|
||||||
|
.then(function (obj) {
|
||||||
|
var payload = {};
|
||||||
|
payload[LUCIDE_TAGS_CACHE_KEY] = obj;
|
||||||
|
payload[LUCIDE_TAGS_CACHE_KEY + "At"] = Date.now();
|
||||||
|
if (chromeLocal && chromeLocal.set) {
|
||||||
|
chromeLocal.set(payload, function () {
|
||||||
|
resolve(obj);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve(obj);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(reject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @returns {Promise<Object<string, string[]>>} slug -> tags */
|
||||||
|
function getLucideTagsMap(chromeLocal, bypassCache) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
if (!chromeLocal || !chromeLocal.get) {
|
||||||
|
fetch(lucideTagsJsonUrl(), { cache: "force-cache" })
|
||||||
|
.then(function (r) {
|
||||||
|
return r.json();
|
||||||
|
})
|
||||||
|
.then(resolve)
|
||||||
|
.catch(reject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (bypassCache) {
|
||||||
|
fetchAndCacheLucideTags(chromeLocal, resolve, reject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chromeLocal.get(
|
||||||
|
[LUCIDE_TAGS_CACHE_KEY, LUCIDE_TAGS_CACHE_KEY + "At"],
|
||||||
|
function (stored) {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
fetchAndCacheLucideTags(chromeLocal, resolve, reject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = stored[LUCIDE_TAGS_CACHE_KEY];
|
||||||
|
var at = stored[LUCIDE_TAGS_CACHE_KEY + "At"];
|
||||||
|
if (
|
||||||
|
data &&
|
||||||
|
typeof data === "object" &&
|
||||||
|
at &&
|
||||||
|
Date.now() - at < LUCIDE_TAGS_MAX_AGE_MS
|
||||||
|
) {
|
||||||
|
resolve(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fetchAndCacheLucideTags(chromeLocal, resolve, reject);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object<string,string[]>} tagsMap
|
||||||
|
* @param {string} query
|
||||||
|
* @param {number} limit
|
||||||
|
* @returns {string[]} slugs
|
||||||
|
*/
|
||||||
|
function searchLucideSlugs(tagsMap, query, limit) {
|
||||||
|
var lim = limit != null ? limit : 60;
|
||||||
|
var q = String(query || "")
|
||||||
|
.toLowerCase()
|
||||||
|
.trim();
|
||||||
|
if (!tagsMap || !q) return [];
|
||||||
|
var matches = [];
|
||||||
|
for (var slug in tagsMap) {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(tagsMap, slug)) continue;
|
||||||
|
var hay =
|
||||||
|
slug +
|
||||||
|
" " +
|
||||||
|
(Array.isArray(tagsMap[slug]) ? tagsMap[slug].join(" ") : "");
|
||||||
|
if (hay.toLowerCase().indexOf(q) === -1) continue;
|
||||||
|
matches.push(slug);
|
||||||
|
}
|
||||||
|
matches.sort(function (a, b) {
|
||||||
|
var al = a.toLowerCase();
|
||||||
|
var bl = b.toLowerCase();
|
||||||
|
var ap = al.indexOf(q) === 0 ? 0 : 1;
|
||||||
|
var bp = bl.indexOf(q) === 0 ? 0 : 1;
|
||||||
|
if (ap !== bp) return ap - bp;
|
||||||
|
return al.localeCompare(bl);
|
||||||
|
});
|
||||||
|
return matches.slice(0, lim);
|
||||||
|
}
|
||||||
+36
-11
@@ -1,13 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "Video Speed Controller",
|
"name": "Speeder",
|
||||||
"short_name": "videospeed",
|
"short_name": "Speeder",
|
||||||
"version": "1.1.3",
|
"version": "5.1.6",
|
||||||
"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 (New and improved version of \"Video Speed Controller\")",
|
||||||
"homepage_url": "https://github.com/SoPat712/videospeed",
|
"homepage_url": "https://github.com/SoPat712/speeder",
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "{ed860648-f54f-4dc9-9a0d-501aec4313f5}"
|
"id": "{ed860648-f54f-4dc9-9a0d-501aec4313f5}",
|
||||||
|
"data_collection_permissions": {
|
||||||
|
"required": [
|
||||||
|
"none"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"icons": {
|
"icons": {
|
||||||
@@ -15,7 +20,15 @@
|
|||||||
"48": "icons/icon48.png",
|
"48": "icons/icon48.png",
|
||||||
"128": "icons/icon128.png"
|
"128": "icons/icon128.png"
|
||||||
},
|
},
|
||||||
"permissions": ["storage"],
|
"background": {
|
||||||
|
"scripts": [
|
||||||
|
"background.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"storage",
|
||||||
|
"https://cdn.jsdelivr.net/*"
|
||||||
|
],
|
||||||
"options_ui": {
|
"options_ui": {
|
||||||
"page": "options.html",
|
"page": "options.html",
|
||||||
"open_in_tab": true
|
"open_in_tab": true
|
||||||
@@ -31,16 +44,28 @@
|
|||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"all_frames": true,
|
"all_frames": true,
|
||||||
"matches": ["http://*/*", "https://*/*", "file:///*"],
|
"matches": [
|
||||||
|
"http://*/*",
|
||||||
|
"https://*/*",
|
||||||
|
"file:///*"
|
||||||
|
],
|
||||||
"match_about_blank": true,
|
"match_about_blank": true,
|
||||||
"exclude_matches": [
|
"exclude_matches": [
|
||||||
"https://plus.google.com/hangouts/*",
|
"https://plus.google.com/hangouts/*",
|
||||||
"https://hangouts.google.com/*",
|
"https://hangouts.google.com/*",
|
||||||
"https://meet.google.com/*"
|
"https://meet.google.com/*"
|
||||||
],
|
],
|
||||||
"css": ["inject.css"],
|
"css": [
|
||||||
"js": ["inject.js"]
|
"inject.css"
|
||||||
|
],
|
||||||
|
"js": [
|
||||||
|
"ui-icons.js",
|
||||||
|
"inject.js"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"web_accessible_resources": ["inject.css", "shadow.css"]
|
"web_accessible_resources": [
|
||||||
|
"inject.css",
|
||||||
|
"shadow.css"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+1032
-82
@@ -1,112 +1,1062 @@
|
|||||||
|
:root {
|
||||||
|
--bg: #f4f5f7;
|
||||||
|
--panel: #ffffff;
|
||||||
|
--panel-subtle: #fafbfc;
|
||||||
|
--border: #e2e5e9;
|
||||||
|
--border-strong: #d4d9e0;
|
||||||
|
--text: #17191c;
|
||||||
|
--muted: #626b76;
|
||||||
|
--accent: #111827;
|
||||||
|
--danger: #b42318;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
/* Avoid coupling to the browser viewport: embedded options (e.g. Add-ons
|
||||||
|
* Manager iframe) must size to content, not 100vh, or a large empty band
|
||||||
|
* appears below the page. */
|
||||||
|
height: auto;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding-left: 15px;
|
min-height: 0;
|
||||||
padding-top: 53px;
|
padding: 24px 16px 40px;
|
||||||
font-family: sans-serif;
|
background: var(--bg);
|
||||||
font-size: 12px;
|
color: var(--text);
|
||||||
color: rgb(48, 57, 66);
|
font: 14px/1.45 "Avenir Next", "SF Pro Text", "Segoe UI", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-shell {
|
||||||
|
width: min(880px, 100%);
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-block {
|
||||||
|
max-width: 560px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2,
|
||||||
h3 {
|
h3,
|
||||||
font-weight: normal;
|
h4 {
|
||||||
line-height: 1;
|
margin: 0;
|
||||||
user-select: none;
|
font-family: "Avenir Next", "SF Pro Display", "Segoe UI", sans-serif;
|
||||||
cursor: default;
|
font-weight: 600;
|
||||||
}
|
letter-spacing: -0.01em;
|
||||||
h1 {
|
|
||||||
font-size: 1.5em;
|
|
||||||
margin: 21px 0 13px;
|
|
||||||
}
|
|
||||||
h3 {
|
|
||||||
font-size: 1.2em;
|
|
||||||
margin-bottom: 0.8em;
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0.65em 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
h1 {
|
||||||
position: fixed;
|
font-size: 28px;
|
||||||
top: 0;
|
line-height: 1.1;
|
||||||
left: 15px;
|
|
||||||
right: 0;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
background: linear-gradient(white, white 40%, rgba(255, 255, 255, 0.92));
|
|
||||||
}
|
}
|
||||||
header,
|
|
||||||
section {
|
h3 {
|
||||||
min-width: 600px;
|
font-size: 16px;
|
||||||
max-width: 738px;
|
line-height: 1.25;
|
||||||
}
|
}
|
||||||
section {
|
|
||||||
padding-left: 18px;
|
h4 {
|
||||||
margin-top: 8px;
|
font-size: 15px;
|
||||||
margin-bottom: 24px;
|
line-height: 1.3;
|
||||||
}
|
}
|
||||||
section h3 {
|
|
||||||
margin-left: -18px;
|
.page-subtitle,
|
||||||
|
.section-intro {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 26px;
|
||||||
|
padding: 0 9px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--panel);
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-stack {
|
||||||
|
display: grid;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-card {
|
||||||
|
padding: 18px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-bars-group {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-bars-inner {
|
||||||
|
display: grid;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-card-nested {
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-heading-major {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-heading-major h2 {
|
||||||
|
margin: 0 0 6px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 650;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-heading-major .section-intro {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-heading {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.defaults-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: var(--border);
|
||||||
|
margin: 14px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.defaults-sub-heading {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--muted);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0.75em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a,
|
||||||
|
a:visited {
|
||||||
|
color: var(--text);
|
||||||
|
text-decoration-color: #c6ccd5;
|
||||||
|
text-underline-offset: 0.14em;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover,
|
||||||
|
a:focus {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
padding: 0.08em 0.38em;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
font-family: "SFMono-Regular", Menlo, Consolas, monospace;
|
||||||
|
font-size: 0.92em;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
font: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
-webkit-appearance: none;
|
appearance: none;
|
||||||
position: relative;
|
min-height: 36px;
|
||||||
|
padding: 0 14px;
|
||||||
margin: 0 1px 0 0;
|
border: 1px solid var(--border-strong);
|
||||||
padding: 0 10px;
|
border-radius: 10px;
|
||||||
min-width: 4em;
|
background: var(--panel);
|
||||||
min-height: 2em;
|
color: var(--text);
|
||||||
|
font-weight: 500;
|
||||||
background-image: linear-gradient(#ededed, #ededed 38%, #dedede);
|
cursor: pointer;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.25);
|
transition: background-color 120ms ease, border-color 120ms ease;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"] {
|
button:hover {
|
||||||
width: 75px;
|
background: #f8f9fb;
|
||||||
text-align: center;
|
border-color: #c5ccd5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
button:active {
|
||||||
margin: 5px 0px;
|
background: #f1f3f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:focus-visible,
|
||||||
|
input[type="text"]:focus,
|
||||||
|
select:focus,
|
||||||
|
textarea:focus {
|
||||||
|
outline: 2px solid rgba(17, 24, 39, 0.14);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#save {
|
||||||
|
background: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#save:hover {
|
||||||
|
background: #1f2937;
|
||||||
|
border-color: #1f2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"],
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 36px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--panel);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"]:focus,
|
||||||
|
select:focus,
|
||||||
|
textarea:focus {
|
||||||
|
border-color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="checkbox"] {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
margin: 2px 0 0;
|
||||||
|
accent-color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: inline-block;
|
display: block;
|
||||||
width: 170px;
|
}
|
||||||
vertical-align: top;
|
|
||||||
|
label em {
|
||||||
|
display: block;
|
||||||
|
margin-top: 4px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcuts-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcut-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) 120px 120px;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px 0;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcuts-grid .shortcut-row:first-child {
|
||||||
|
padding-top: 0;
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcut-row.customs {
|
||||||
|
grid-template-columns: minmax(0, 1fr) 120px 120px 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcut-label {
|
||||||
|
color: var(--text);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customKey,
|
||||||
|
.customValue {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addShortcutSelector {
|
||||||
|
width: min(220px, 100%);
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.removeParent,
|
||||||
|
.toggle-site-rule {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 36px;
|
||||||
|
min-width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.removeParent {
|
||||||
|
color: var(--danger);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-site-rule {
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) 160px;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: start;
|
||||||
|
padding: 10px 0;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.row input[type="text"],
|
||||||
|
.row select {
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row.row-checkbox {
|
||||||
|
grid-template-columns: minmax(0, 1fr) 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row.row-checkbox input[type="checkbox"] {
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-card .row:first-of-type {
|
||||||
|
padding-top: 0;
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row.row-controller-margin {
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 260px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.controller-margin-inputs {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 116px));
|
||||||
|
gap: 8px;
|
||||||
|
width: max-content;
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.margin-pad-cell {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
min-width: 116px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.margin-pad-mini {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controller-margin-inputs input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 116px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option.site-rule-margin-option {
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 260px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-override-section {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-content > .site-rule-override-section:first-of-type {
|
||||||
|
margin-top: 0;
|
||||||
|
padding-top: 0;
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-override-lead {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) 24px;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-start;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-override-lead input[type="checkbox"] {
|
||||||
|
justify-self: end;
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-override-lead span {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-override-section .site-override-fields,
|
||||||
|
.site-rule-override-section .site-placement-container,
|
||||||
|
.site-rule-override-section .site-visibility-container,
|
||||||
|
.site-rule-override-section .site-autohide-container,
|
||||||
|
.site-rule-override-section .site-playback-container,
|
||||||
|
.site-rule-override-section .site-opacity-container,
|
||||||
|
.site-rule-override-section .site-subtitleNudge-container {
|
||||||
|
padding-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-editor {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-editor-disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
pointer-events: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-zone-label {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-dropzone {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
min-height: 52px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 2px dashed var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
transition: border-color 150ms ease, background 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-dropzone.cb-over {
|
||||||
|
border-color: var(--accent);
|
||||||
|
background: rgba(17, 24, 39, 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-active-zone:empty::after {
|
||||||
|
content: "Drag buttons here";
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-available-zone:empty::after {
|
||||||
|
content: "All buttons active";
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-block {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 7px 12px 7px 8px;
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--panel);
|
||||||
|
cursor: grab;
|
||||||
|
user-select: none;
|
||||||
|
transition: box-shadow 150ms ease, opacity 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-block:hover {
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-block:active {
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-block.cb-dragging {
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-grip {
|
||||||
|
width: 6px;
|
||||||
|
min-width: 6px;
|
||||||
|
height: 14px;
|
||||||
|
background-image: radial-gradient(circle, currentColor 1px, transparent 1px);
|
||||||
|
background-size: 3px 3px;
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-icon {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-icon svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-icon.cb-icon-nudge-pair {
|
||||||
|
width: auto;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0 4px;
|
||||||
|
gap: 4px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-nudge-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
border-radius: 6px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-nudge-chip[data-nudge-state="on"] {
|
||||||
|
background: #4b9135;
|
||||||
|
border: 1px solid #6ec754;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-nudge-chip[data-nudge-state="off"] {
|
||||||
|
background: #943e3e;
|
||||||
|
border: 1px solid #c06060;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-nudge-chip .vsc-btn-icon svg,
|
||||||
|
.cb-nudge-chip svg {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-nudge-sep {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
opacity: 0.45;
|
||||||
|
color: var(--text);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-lucide-pair select {
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-lucide-search-row {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-lucide-search-row .lucide-search-label {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-search-field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 0 14px 0 12px;
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--panel);
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||||
|
transition: border-color 150ms ease, box-shadow 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-search-field:focus-within {
|
||||||
|
border-color: #9ca3af;
|
||||||
|
box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-search-icon {
|
||||||
|
display: flex;
|
||||||
|
color: var(--muted);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-search-input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 40px;
|
||||||
|
padding: 8px 0;
|
||||||
|
border: 0 !important;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
background: transparent !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-search-input::placeholder {
|
||||||
|
color: var(--muted);
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-search-input:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-results {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
max-height: 220px;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 12px 0;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.lucide-result-tile {
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.lucide-result-tile:hover {
|
||||||
|
background: var(--panel);
|
||||||
|
border-color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.lucide-result-tile .lucide-result-thumb {
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
object-fit: contain;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.lucide-result-tile.lucide-picked {
|
||||||
|
border-color: var(--accent);
|
||||||
|
box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.12);
|
||||||
|
background: var(--panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-status {
|
||||||
|
margin: 8px 0 0;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--muted);
|
||||||
|
min-height: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-preview-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 72px 1fr;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: start;
|
||||||
|
margin-top: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-preview {
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-preview svg {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-actions .lucide-apply {
|
||||||
|
background: #ffffff !important;
|
||||||
|
color: #111827 !important;
|
||||||
|
border: 1px solid var(--border-strong) !important;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-actions .lucide-apply:hover {
|
||||||
|
background: #f3f4f6 !important;
|
||||||
|
border-color: #9ca3af !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-actions .secondary {
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
color: var(--text);
|
||||||
|
border-color: var(--border-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-label {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
#siteRulesContainer {
|
||||||
|
display: grid;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule {
|
||||||
|
padding: 12px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--panel-subtle);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-header {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 36px minmax(0, 1fr) auto;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-pattern {
|
||||||
|
min-width: 0;
|
||||||
|
font-family: "SFMono-Regular", Menlo, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-body {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-content.disabled-rule {
|
||||||
|
opacity: 0.55;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) 160px;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: start;
|
||||||
|
padding: 8px 0;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option-checkbox {
|
||||||
|
grid-template-columns: minmax(0, 1fr) 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option-checkbox > input[type="checkbox"] {
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option > input[type="text"],
|
||||||
|
.site-rule-option > select {
|
||||||
|
justify-self: end;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option.site-rule-margin-option .controller-margin-inputs {
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-body > .site-rule-option:first-child,
|
||||||
|
.site-rule-content > .site-rule-option:first-child {
|
||||||
|
padding-top: 0;
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option > label:not(.site-rule-split-label) {
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-split-label {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) 24px;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-split-label input[type="checkbox"] {
|
||||||
|
justify-self: end;
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option-checkbox > .site-rule-split-label {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-controlbar,
|
||||||
|
.site-rule-shortcuts {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-controlbar > label.site-override-lead,
|
||||||
|
.site-rule-shortcuts > label.site-override-lead {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-controlbar-container,
|
||||||
|
.site-popup-controlbar-container {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-shortcuts-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-shortcuts-container .shortcut-row {
|
||||||
|
grid-template-columns: minmax(0, 1fr) 110px 110px minmax(0, 1fr);
|
||||||
|
padding: 8px 0;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-shortcuts-container .shortcut-row:first-child {
|
||||||
|
padding-top: 0;
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.force-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 8px;
|
||||||
|
width: auto;
|
||||||
|
margin: 0;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.force-label input {
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#status {
|
#status {
|
||||||
color: #9d9d9d;
|
min-height: 1.3em;
|
||||||
display: inline-block;
|
margin-top: 10px;
|
||||||
margin-left: 50px;
|
color: var(--muted);
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
#faq {
|
#status:empty {
|
||||||
margin-top: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
|
||||||
width: 170px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.customForce {
|
|
||||||
display: none;
|
display: none;
|
||||||
width: 250px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.customKey {
|
.support-footer {
|
||||||
color: transparent;
|
padding: 16px 20px;
|
||||||
text-shadow: 0 0 0 #000000;
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-footer p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-footer a {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.lucide-icon-preview-row {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcut-row,
|
||||||
|
.shortcut-row.customs,
|
||||||
|
.row,
|
||||||
|
.row.row-checkbox,
|
||||||
|
.site-rule-option,
|
||||||
|
.site-shortcuts-container .shortcut-row {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row input[type="text"],
|
||||||
|
.row select {
|
||||||
|
justify-self: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-option > input[type="text"],
|
||||||
|
.site-rule-option > select {
|
||||||
|
justify-self: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-override-lead {
|
||||||
|
grid-template-columns: minmax(0, 1fr) 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-row button,
|
||||||
|
#addShortcutSelector {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-header {
|
||||||
|
grid-template-columns: 36px minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.remove-site-rule {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 520px) {
|
||||||
|
body {
|
||||||
|
padding: 16px 12px 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-card {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-bars-group {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-rule-header {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg: #111315;
|
||||||
|
--panel: #171a1d;
|
||||||
|
--panel-subtle: #1b1f23;
|
||||||
|
--border: #2b3138;
|
||||||
|
--border-strong: #3a414a;
|
||||||
|
--text: #f2f4f6;
|
||||||
|
--muted: #a0a8b2;
|
||||||
|
--accent: #f2f4f6;
|
||||||
|
--danger: #ff8a80;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
a,
|
||||||
|
a:visited {
|
||||||
|
color: #f2f4f6;
|
||||||
|
text-decoration-color: #4b5563;
|
||||||
|
}
|
||||||
|
|
||||||
|
#save {
|
||||||
|
background: #f2f4f6;
|
||||||
|
border-color: #f2f4f6;
|
||||||
|
color: #111315;
|
||||||
|
}
|
||||||
|
|
||||||
|
#save:hover {
|
||||||
|
background: #dfe3e8;
|
||||||
|
border-color: #dfe3e8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cb-dropzone.cb-over {
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"]:focus,
|
||||||
|
select:focus,
|
||||||
|
textarea:focus {
|
||||||
|
border-color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-search-field:focus-within {
|
||||||
|
border-color: #6b7280;
|
||||||
|
box-shadow: 0 0 0 3px rgba(242, 244, 246, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-actions .lucide-apply {
|
||||||
|
background: #ffffff !important;
|
||||||
|
color: #111315 !important;
|
||||||
|
border-color: #e5e7eb !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lucide-icon-actions .lucide-apply:hover {
|
||||||
|
background: #f3f4f6 !important;
|
||||||
|
border-color: #d1d5db !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.lucide-result-tile .lucide-result-thumb {
|
||||||
|
filter: brightness(0) invert(1);
|
||||||
|
opacity: 0.92;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+694
-225
@@ -1,244 +1,713 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Video Speed Controller: Options</title>
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Speeder Settings</title>
|
||||||
<link rel="stylesheet" href="options.css" />
|
<link rel="stylesheet" href="options.css" />
|
||||||
|
<script src="ui-icons.js"></script>
|
||||||
|
<script src="lucide-client.js"></script>
|
||||||
<script src="options.js"></script>
|
<script src="options.js"></script>
|
||||||
|
<script src="importExport.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<div class="page-shell">
|
||||||
<h1>Video Speed Controller</h1>
|
<header class="page-header">
|
||||||
</header>
|
<div class="title-row">
|
||||||
|
<div class="title-block">
|
||||||
|
<h1>Speeder settings</h1>
|
||||||
|
<p class="page-subtitle">Shortcuts, defaults, and site rules.</p>
|
||||||
|
</div>
|
||||||
|
<div class="version">v<span id="app-version"></span></div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
<section id="customs">
|
<main class="settings-stack">
|
||||||
<h3>Shortcuts</h3>
|
<section id="customs" class="settings-card">
|
||||||
<div class="row customs" id="display">
|
<div class="section-heading">
|
||||||
<select class="customDo">
|
<h3>Shortcuts</h3>
|
||||||
<option value="display">Show/hide controller</option>
|
<p class="section-intro">Backspace clears a shortcut. Escape disables it.</p>
|
||||||
</select>
|
</div>
|
||||||
<input
|
<div class="shortcuts-grid">
|
||||||
class="customKey"
|
<div class="shortcut-row" id="display" data-action="display">
|
||||||
type="text"
|
<div class="shortcut-label">Show/hide controller</div>
|
||||||
value=""
|
<input
|
||||||
placeholder="press a key"
|
class="customKey"
|
||||||
/>
|
type="text"
|
||||||
<input class="customValue" type="text" placeholder="value (0.10)" />
|
value=""
|
||||||
<select class="customForce">
|
placeholder="press a key"
|
||||||
<option value="false">Do not disable website key bindings</option>
|
/>
|
||||||
<option value="true">Disable website key bindings</option>
|
<input
|
||||||
</select>
|
class="customValue"
|
||||||
</div>
|
type="text"
|
||||||
<div class="row customs" id="slower">
|
placeholder="value"
|
||||||
<select class="customDo">
|
value="N/A"
|
||||||
<option value="slower">Decrease speed</option>
|
disabled
|
||||||
</select>
|
/>
|
||||||
<input
|
</div>
|
||||||
class="customKey"
|
<div class="shortcut-row" id="move" data-action="move">
|
||||||
type="text"
|
<div class="shortcut-label">Move controller</div>
|
||||||
value=""
|
<input
|
||||||
placeholder="press a key"
|
class="customKey"
|
||||||
/>
|
type="text"
|
||||||
<input class="customValue" type="text" placeholder="value (0.10)" />
|
value=""
|
||||||
<select class="customForce">
|
placeholder="press a key"
|
||||||
<option value="false">Do not disable website key bindings</option>
|
/>
|
||||||
<option value="true">Disable website key bindings</option>
|
<input
|
||||||
</select>
|
class="customValue"
|
||||||
</div>
|
type="text"
|
||||||
<div class="row customs" id="faster">
|
placeholder="value"
|
||||||
<select class="customDo">
|
value="N/A"
|
||||||
<option value="faster">Increase speed</option>
|
disabled
|
||||||
</select>
|
/>
|
||||||
<input
|
</div>
|
||||||
class="customKey"
|
<div class="shortcut-row" id="slower" data-action="slower">
|
||||||
type="text"
|
<div class="shortcut-label">Decrease speed</div>
|
||||||
value=""
|
<input
|
||||||
placeholder="press a key"
|
class="customKey"
|
||||||
/>
|
type="text"
|
||||||
<input class="customValue" type="text" placeholder="value (0.10)" />
|
value=""
|
||||||
<select class="customForce">
|
placeholder="press a key"
|
||||||
<option value="false">Do not disable website key bindings</option>
|
/>
|
||||||
<option value="true">Disable website key bindings</option>
|
<input
|
||||||
</select>
|
class="customValue"
|
||||||
</div>
|
type="text"
|
||||||
<div class="row customs" id="rewind">
|
placeholder="value (0.10)"
|
||||||
<select class="customDo">
|
/>
|
||||||
<option value="rewind">Rewind</option>
|
</div>
|
||||||
</select>
|
<div class="shortcut-row" id="faster" data-action="faster">
|
||||||
<input
|
<div class="shortcut-label">Increase speed</div>
|
||||||
class="customKey"
|
<input
|
||||||
type="text"
|
class="customKey"
|
||||||
value=""
|
type="text"
|
||||||
placeholder="press a key"
|
value=""
|
||||||
/>
|
placeholder="press a key"
|
||||||
<input class="customValue" type="text" placeholder="value (10)" />
|
/>
|
||||||
<select class="customForce">
|
<input
|
||||||
<option value="false">Do not disable website key bindings</option>
|
class="customValue"
|
||||||
<option value="true">Disable website key bindings</option>
|
type="text"
|
||||||
</select>
|
placeholder="value (0.10)"
|
||||||
</div>
|
/>
|
||||||
<div class="row customs" id="advance">
|
</div>
|
||||||
<select class="customDo">
|
<div class="shortcut-row" id="rewind" data-action="rewind">
|
||||||
<option value="advance">Advance</option>
|
<div class="shortcut-label">Rewind</div>
|
||||||
</select>
|
<input
|
||||||
<input
|
class="customKey"
|
||||||
class="customKey"
|
type="text"
|
||||||
type="text"
|
value=""
|
||||||
value=""
|
placeholder="press a key"
|
||||||
placeholder="press a key"
|
/>
|
||||||
/>
|
<input
|
||||||
<input class="customValue" type="text" placeholder="value (10)" />
|
class="customValue"
|
||||||
<select class="customForce">
|
type="text"
|
||||||
<option value="false">Do not disable website key bindings</option>
|
placeholder="value (10)"
|
||||||
<option value="true">Disable website key bindings</option>
|
/>
|
||||||
</select>
|
</div>
|
||||||
</div>
|
<div class="shortcut-row" id="advance" data-action="advance">
|
||||||
<div class="row customs" id="reset">
|
<div class="shortcut-label">Advance</div>
|
||||||
<select class="customDo">
|
<input
|
||||||
<option value="reset">Reset speed</option>
|
class="customKey"
|
||||||
</select>
|
type="text"
|
||||||
<input
|
value=""
|
||||||
class="customKey"
|
placeholder="press a key"
|
||||||
type="text"
|
/>
|
||||||
value=""
|
<input
|
||||||
placeholder="press a key"
|
class="customValue"
|
||||||
/>
|
type="text"
|
||||||
<input
|
placeholder="value (10)"
|
||||||
class="customValue"
|
/>
|
||||||
type="text"
|
</div>
|
||||||
placeholder="value (1.00)"
|
<div class="shortcut-row" id="reset" data-action="reset">
|
||||||
disabled
|
<div class="shortcut-label">Reset speed</div>
|
||||||
/>
|
<input
|
||||||
<select class="customForce">
|
class="customKey"
|
||||||
<option value="false">Do not disable website key bindings</option>
|
type="text"
|
||||||
<option value="true">Disable website key bindings</option>
|
value=""
|
||||||
</select>
|
placeholder="press a key"
|
||||||
</div>
|
/>
|
||||||
<div class="row customs" id="fast">
|
<input
|
||||||
<select class="customDo">
|
class="customValue"
|
||||||
<option value="fast">Preferred speed</option>
|
type="text"
|
||||||
</select>
|
placeholder="value"
|
||||||
<input
|
value="N/A"
|
||||||
class="customKey"
|
disabled
|
||||||
type="text"
|
/>
|
||||||
value=""
|
</div>
|
||||||
placeholder="press a key"
|
<div class="shortcut-row" id="fast" data-action="fast">
|
||||||
/>
|
<div class="shortcut-label">Preferred speed</div>
|
||||||
<input class="customValue" type="text" placeholder="value (1.80)" />
|
<input
|
||||||
<select class="customForce">
|
class="customKey"
|
||||||
<option value="false">Do not disable website key bindings</option>
|
type="text"
|
||||||
<option value="true">Disable website key bindings</option>
|
value=""
|
||||||
</select>
|
placeholder="press a key"
|
||||||
</div>
|
/>
|
||||||
|
<input
|
||||||
|
class="customValue"
|
||||||
|
type="text"
|
||||||
|
placeholder="value (1.80)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="shortcut-row"
|
||||||
|
id="toggleSubtitleNudge"
|
||||||
|
data-action="toggleSubtitleNudge"
|
||||||
|
>
|
||||||
|
<div class="shortcut-label">Toggle subtitle nudge</div>
|
||||||
|
<input
|
||||||
|
class="customKey"
|
||||||
|
type="text"
|
||||||
|
value=""
|
||||||
|
placeholder="press a key"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
class="customValue"
|
||||||
|
type="text"
|
||||||
|
placeholder="value"
|
||||||
|
value="N/A"
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button id="add">Add New</button>
|
<select id="addShortcutSelector">
|
||||||
</section>
|
<option value="">Add shortcut…</option>
|
||||||
|
</select>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section>
|
<section id="generalSettings" class="settings-card">
|
||||||
<h3>Other</h3>
|
<div class="section-heading">
|
||||||
<div class="row">
|
<h3>Defaults</h3>
|
||||||
<label for="enabled">Enable</label>
|
<p class="section-intro">Used unless a site rule overrides it.</p>
|
||||||
<input id="enabled" type="checkbox" />
|
</div>
|
||||||
</div>
|
|
||||||
<div class="row">
|
<h4 class="defaults-sub-heading">General</h4>
|
||||||
<label for="startHidden">Hide controller by default</label>
|
|
||||||
<input id="startHidden" type="checkbox" />
|
<div class="row row-checkbox">
|
||||||
</div>
|
<label for="enabled">Enable</label>
|
||||||
<div class="row">
|
<input id="enabled" type="checkbox" />
|
||||||
<label for="rememberSpeed">Remember playback speed</label>
|
</div>
|
||||||
<input id="rememberSpeed" type="checkbox" />
|
<div class="row row-checkbox">
|
||||||
</div>
|
<label for="audioBoolean">Work on audio</label>
|
||||||
<div class="row">
|
<input id="audioBoolean" type="checkbox" />
|
||||||
<label for="forceLastSavedSpeed"
|
</div>
|
||||||
>Force last saved speed<br />
|
|
||||||
<em
|
<div class="defaults-divider"></div>
|
||||||
>Useful for video players that override the speeds set by
|
<h4 class="defaults-sub-heading">Playback</h4>
|
||||||
VideoSpeed</em
|
|
||||||
></label
|
<div class="row row-checkbox">
|
||||||
|
<label for="rememberSpeed">Remember playback speed</label>
|
||||||
|
<input id="rememberSpeed" type="checkbox" />
|
||||||
|
</div>
|
||||||
|
<div class="row row-checkbox">
|
||||||
|
<label for="forceLastSavedSpeed"
|
||||||
|
>Force last saved speed<br />
|
||||||
|
<em
|
||||||
|
>Useful when a video player tries to override the speed you set
|
||||||
|
in Speeder.</em
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<input id="forceLastSavedSpeed" type="checkbox" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="defaults-divider"></div>
|
||||||
|
<h4 class="defaults-sub-heading">Controller</h4>
|
||||||
|
|
||||||
|
<div class="row row-checkbox">
|
||||||
|
<label for="startHidden">Hide controller by default</label>
|
||||||
|
<input id="startHidden" type="checkbox" />
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="controllerLocation">Default controller location</label>
|
||||||
|
<select id="controllerLocation">
|
||||||
|
<option value="top-left">Top left</option>
|
||||||
|
<option value="top-center">Top center</option>
|
||||||
|
<option value="top-right">Top right</option>
|
||||||
|
<option value="middle-right">Middle right</option>
|
||||||
|
<option value="bottom-right">Bottom right</option>
|
||||||
|
<option value="bottom-center">Bottom center</option>
|
||||||
|
<option value="bottom-left">Bottom left</option>
|
||||||
|
<option value="middle-left">Middle left</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="controllerOpacity">Controller opacity</label>
|
||||||
|
<input id="controllerOpacity" type="text" value="" />
|
||||||
|
</div>
|
||||||
|
<div class="row row-controller-margin">
|
||||||
|
<label for="controllerMarginTop"
|
||||||
|
>Controller margin (px)<br />
|
||||||
|
<em
|
||||||
|
>Shifts the whole control from its preset position (CSS
|
||||||
|
margins). Top and bottom. 0–200.</em
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<div class="controller-margin-inputs" aria-label="Controller margin in pixels">
|
||||||
|
<div class="margin-pad-cell">
|
||||||
|
<span class="margin-pad-mini">Top</span>
|
||||||
|
<input id="controllerMarginTop" type="text" inputmode="numeric" placeholder="0" />
|
||||||
|
</div>
|
||||||
|
<div class="margin-pad-cell">
|
||||||
|
<span class="margin-pad-mini">Bottom</span>
|
||||||
|
<input id="controllerMarginBottom" type="text" inputmode="numeric" placeholder="0" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row row-checkbox">
|
||||||
|
<label for="hideWithControls"
|
||||||
|
>Hide with controls<br />
|
||||||
|
<em
|
||||||
|
>Fade the controller in and out with the video interface:
|
||||||
|
perfect sync on YouTube, idle-based elsewhere.</em
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<input id="hideWithControls" type="checkbox" />
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="hideWithControlsTimer"
|
||||||
|
>Auto-hide timer (seconds)<br />
|
||||||
|
<em
|
||||||
|
>Seconds of inactivity before hiding: 0.1–15 for
|
||||||
|
non-YouTube sites.</em
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<input id="hideWithControlsTimer" type="text" placeholder="2" />
|
||||||
|
</div>
|
||||||
|
<div class="defaults-divider"></div>
|
||||||
|
<h4 class="defaults-sub-heading">Subtitle sync</h4>
|
||||||
|
|
||||||
|
<div class="row row-checkbox">
|
||||||
|
<label for="enableSubtitleNudge"
|
||||||
|
>Enable subtitle nudge<br /><em
|
||||||
|
>Makes tiny playback changes to help keep subtitles aligned.</em
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<input id="enableSubtitleNudge" type="checkbox" />
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="subtitleNudgeInterval"
|
||||||
|
>Nudge interval (milliseconds)<br /><em
|
||||||
|
>How often to nudge: 10–1000. Smaller values are more
|
||||||
|
frequent. Default: 50.</em
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="subtitleNudgeInterval"
|
||||||
|
type="text"
|
||||||
|
value=""
|
||||||
|
placeholder="50"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
id="controlBarsGroup"
|
||||||
|
class="settings-card control-bars-group"
|
||||||
|
aria-labelledby="controlBarsGroupHeading"
|
||||||
>
|
>
|
||||||
<input id="forceLastSavedSpeed" type="checkbox" />
|
<div class="section-heading section-heading-major">
|
||||||
</div>
|
<h2 id="controlBarsGroupHeading">Control bars</h2>
|
||||||
<div class="row">
|
<p class="section-intro">
|
||||||
<label for="audioBoolean">Work on audio</label>
|
In-page hover bar, extension popup bar, and Lucide icons for
|
||||||
<input id="audioBoolean" type="checkbox" />
|
buttons.
|
||||||
</div>
|
</p>
|
||||||
<div class="row">
|
</div>
|
||||||
<label for="controllerOpacity">Controller opacity</label>
|
<div class="control-bars-inner">
|
||||||
<input id="controllerOpacity" type="text" value="" />
|
<section id="controlBarSettings" class="settings-card settings-card-nested">
|
||||||
</div>
|
<div class="section-heading">
|
||||||
<div class="row">
|
<h3>Hover control bar</h3>
|
||||||
<label for="blacklist"
|
<p class="section-intro">
|
||||||
>Sites on which extension is disabled<br />
|
Drag blocks to reorder. Move between Active and Available to
|
||||||
(one per line)<br />
|
show or hide buttons.
|
||||||
<br />
|
</p>
|
||||||
<em>
|
</div>
|
||||||
<a href="https://www.regexpal.com/">Regex</a> is supported.<br />
|
<div class="cb-editor">
|
||||||
Be sure it is in "//g" format.<br />
|
<div class="cb-zone">
|
||||||
ie: /(.+)youtube\.com(\/*)$/gi
|
<div class="cb-zone-label">Active</div>
|
||||||
</em>
|
<div
|
||||||
</label>
|
id="controlBarActive"
|
||||||
<textarea id="blacklist" rows="10" cols="50"></textarea>
|
class="cb-dropzone cb-active-zone"
|
||||||
</div>
|
></div>
|
||||||
</section>
|
</div>
|
||||||
|
<div class="cb-zone">
|
||||||
|
<div class="cb-zone-label">Available</div>
|
||||||
|
<div
|
||||||
|
id="controlBarAvailable"
|
||||||
|
class="cb-dropzone cb-available-zone"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section id="nudgeSettings">
|
<section id="popupControlBarSettings" class="settings-card settings-card-nested">
|
||||||
<h3>Subtitle Nudge Settings (Experimental - YouTube Only)</h3>
|
<div class="section-heading">
|
||||||
<div class="row">
|
<h3>Popup control bar</h3>
|
||||||
<label for="enableSubtitleNudge"
|
<p class="section-intro">
|
||||||
>Enable Subtitle Nudge <br /><em
|
Configure which buttons appear in the browser popup control bar.
|
||||||
>Periodically 'nudges' video speed by a tiny amount to help keep
|
</p>
|
||||||
subtitles in sync on some sites (e.g. YouTube).</em
|
</div>
|
||||||
>
|
<div class="row row-checkbox">
|
||||||
</label>
|
<label for="showPopupControlBar">Show popup control bar</label>
|
||||||
<input id="enableSubtitleNudge" type="checkbox" />
|
<input id="showPopupControlBar" type="checkbox" />
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row row-checkbox">
|
||||||
<label for="subtitleNudgeInterval"
|
<label for="popupMatchHoverControls">Match hover controls</label>
|
||||||
>Nudge Interval (milliseconds) <br /><em
|
<input id="popupMatchHoverControls" type="checkbox" />
|
||||||
>How often to nudge (e.g., 25-1000). Smaller values are more
|
</div>
|
||||||
frequent. Default: 25.</em
|
<div id="popupCbEditorWrap" class="cb-editor cb-editor-disabled">
|
||||||
>
|
<div class="cb-zone">
|
||||||
</label>
|
<div class="cb-zone-label">Active</div>
|
||||||
<input
|
<div
|
||||||
id="subtitleNudgeInterval"
|
id="popupControlBarActive"
|
||||||
type="text"
|
class="cb-dropzone cb-active-zone"
|
||||||
value=""
|
></div>
|
||||||
placeholder="25"
|
</div>
|
||||||
/>
|
<div class="cb-zone">
|
||||||
</div>
|
<div class="cb-zone-label">Available</div>
|
||||||
<div class="row">
|
<div
|
||||||
<label for="subtitleNudgeAmount"
|
id="popupControlBarAvailable"
|
||||||
>Nudge Amount (decimal) <br /><em
|
class="cb-dropzone cb-available-zone"
|
||||||
>How much to change speed by (e.g., 0.001). Very small values
|
></div>
|
||||||
recommended. Default: 0.001.</em
|
</div>
|
||||||
>
|
</div>
|
||||||
</label>
|
</section>
|
||||||
<input
|
|
||||||
id="subtitleNudgeAmount"
|
|
||||||
type="text"
|
|
||||||
value=""
|
|
||||||
placeholder="0.001"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<button id="save">Save</button>
|
<section id="lucideIconSettings" class="settings-card settings-card-nested">
|
||||||
<button id="restore">Restore Defaults</button>
|
<div class="section-heading">
|
||||||
<button id="experimental">Show Experimental Features</button>
|
<h3>Button icons (Lucide)</h3>
|
||||||
|
<p class="section-intro">
|
||||||
|
Search icons from the
|
||||||
|
<a
|
||||||
|
href="https://lucide.dev"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>Lucide</a
|
||||||
|
>
|
||||||
|
set (fetched from jsDelivr). Custom icons are cached in local
|
||||||
|
storage and included when you export settings. Subtitle nudge
|
||||||
|
icons use two menu entries (enabled and disabled), not the bar
|
||||||
|
block id
|
||||||
|
<code>nudge</code>.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="row row-lucide-pair">
|
||||||
|
<label for="lucideIconActionSelect">Controller action</label>
|
||||||
|
<select id="lucideIconActionSelect"></select>
|
||||||
|
</div>
|
||||||
|
<div class="row row-lucide-search-row">
|
||||||
|
<label for="lucideIconSearch" class="lucide-search-label"
|
||||||
|
>Search icons</label
|
||||||
|
>
|
||||||
|
<div class="lucide-search-field">
|
||||||
|
<span class="lucide-search-icon" aria-hidden="true">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="18"
|
||||||
|
height="18"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<circle cx="11" cy="11" r="8" />
|
||||||
|
<path d="m21 21-4.3-4.3" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
type="search"
|
||||||
|
id="lucideIconSearch"
|
||||||
|
class="lucide-search-input"
|
||||||
|
placeholder="Search by name or tag (e.g. star, arrow, media)…"
|
||||||
|
autocomplete="off"
|
||||||
|
spellcheck="false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
id="lucideIconResults"
|
||||||
|
class="lucide-icon-results"
|
||||||
|
role="listbox"
|
||||||
|
aria-label="Matching Lucide icons"
|
||||||
|
></div>
|
||||||
|
<p id="lucideIconStatus" class="lucide-icon-status" aria-live="polite"></p>
|
||||||
|
<div class="lucide-icon-preview-row">
|
||||||
|
<div
|
||||||
|
id="lucideIconPreview"
|
||||||
|
class="lucide-icon-preview"
|
||||||
|
aria-live="polite"
|
||||||
|
></div>
|
||||||
|
<div class="lucide-icon-actions">
|
||||||
|
<button type="button" id="lucideIconApply" class="lucide-apply">
|
||||||
|
Apply to action
|
||||||
|
</button>
|
||||||
|
<button type="button" id="lucideIconClearAction" class="secondary">
|
||||||
|
Clear this action
|
||||||
|
</button>
|
||||||
|
<button type="button" id="lucideIconClearAll" class="secondary">
|
||||||
|
Clear all custom icons
|
||||||
|
</button>
|
||||||
|
<button type="button" id="lucideIconReloadTags" class="secondary">
|
||||||
|
Refresh icon list from network
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div id="status"></div>
|
<section id="siteRules" class="settings-card">
|
||||||
|
<div class="section-heading">
|
||||||
|
<h3>Site rules</h3>
|
||||||
|
<p class="section-intro">
|
||||||
|
Use plain domains or
|
||||||
|
<a
|
||||||
|
href="https://www.regexpal.com/"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>Regex</a
|
||||||
|
>
|
||||||
|
patterns like <code>/(.+)youtube\.com(\/*)$/gi</code>. Turn on a
|
||||||
|
row only when you want that group to override the general defaults
|
||||||
|
above.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div id="siteRulesContainer"></div>
|
||||||
|
<button id="addSiteRule" type="button">Add Site Rule</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div id="faq">
|
<template id="siteRuleTemplate">
|
||||||
<hr />
|
<div class="site-rule">
|
||||||
|
<div class="site-rule-header">
|
||||||
|
<button type="button" class="toggle-site-rule" title="Expand/Collapse">+</button>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="site-pattern"
|
||||||
|
placeholder="e.g., youtube.com or /regex/gi"
|
||||||
|
/>
|
||||||
|
<button type="button" class="remove-site-rule">Remove</button>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-body">
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label class="site-rule-split-label">
|
||||||
|
<span>Enable Speeder on this site</span>
|
||||||
|
<input type="checkbox" class="site-enabled" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-content">
|
||||||
|
<div class="site-rule-override-section">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override placement for this site</span>
|
||||||
|
<input type="checkbox" class="override-placement" />
|
||||||
|
</label>
|
||||||
|
<div class="site-placement-container" style="display: none">
|
||||||
|
<div class="site-rule-option site-rule-option-field">
|
||||||
|
<label>Default controller location:</label>
|
||||||
|
<select class="site-controllerLocation">
|
||||||
|
<option value="top-left">Top left</option>
|
||||||
|
<option value="top-center">Top center</option>
|
||||||
|
<option value="top-right">Top right</option>
|
||||||
|
<option value="middle-right">Middle right</option>
|
||||||
|
<option value="bottom-right">Bottom right</option>
|
||||||
|
<option value="bottom-center">Bottom center</option>
|
||||||
|
<option value="bottom-left">Bottom left</option>
|
||||||
|
<option value="middle-left">Middle left</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-option site-rule-margin-option">
|
||||||
|
<label
|
||||||
|
>Controller margin (px):<br /><em
|
||||||
|
>Shifts the whole control. 0–200.</em
|
||||||
|
></label
|
||||||
|
>
|
||||||
|
<div class="controller-margin-inputs">
|
||||||
|
<div class="margin-pad-cell">
|
||||||
|
<span class="margin-pad-mini">T</span>
|
||||||
|
<input type="text" class="site-controllerMarginTop" inputmode="numeric" placeholder="0" />
|
||||||
|
</div>
|
||||||
|
<div class="margin-pad-cell">
|
||||||
|
<span class="margin-pad-mini">B</span>
|
||||||
|
<input type="text" class="site-controllerMarginBottom" inputmode="numeric" placeholder="0" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-override-section">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override hide-by-default for this site</span>
|
||||||
|
<input type="checkbox" class="override-visibility" />
|
||||||
|
</label>
|
||||||
|
<div class="site-visibility-container" style="display: none">
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label>Hide controller by default:</label>
|
||||||
|
<input type="checkbox" class="site-startHidden" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-override-section">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override auto-hide for this site</span>
|
||||||
|
<input type="checkbox" class="override-autohide" />
|
||||||
|
</label>
|
||||||
|
<div class="site-autohide-container" style="display: none">
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label class="site-rule-split-label">
|
||||||
|
<span>Hide with controls (idle-based)</span>
|
||||||
|
<input type="checkbox" class="site-hideWithControls" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-option site-rule-option-field">
|
||||||
|
<label>Auto-hide timer (0.1–15s):</label>
|
||||||
|
<input type="text" class="site-hideWithControlsTimer" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-override-section">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override playback for this site</span>
|
||||||
|
<input type="checkbox" class="override-playback" />
|
||||||
|
</label>
|
||||||
|
<div class="site-playback-container" style="display: none">
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label>Remember playback speed:</label>
|
||||||
|
<input type="checkbox" class="site-rememberSpeed" />
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label>Force last saved speed:</label>
|
||||||
|
<input type="checkbox" class="site-forceLastSavedSpeed" />
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label>Work on audio:</label>
|
||||||
|
<input type="checkbox" class="site-audioBoolean" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-override-section">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override opacity for this site</span>
|
||||||
|
<input type="checkbox" class="override-opacity" />
|
||||||
|
</label>
|
||||||
|
<div class="site-opacity-container" style="display: none">
|
||||||
|
<div class="site-rule-option site-rule-option-field">
|
||||||
|
<label>Controller opacity:</label>
|
||||||
|
<input type="text" class="site-controllerOpacity" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-override-section">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override subtitle nudge for this site</span>
|
||||||
|
<input type="checkbox" class="override-subtitleNudge" />
|
||||||
|
</label>
|
||||||
|
<div class="site-subtitleNudge-container" style="display: none">
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label>Enable subtitle nudge:</label>
|
||||||
|
<input type="checkbox" class="site-enableSubtitleNudge" />
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-option site-rule-option-field">
|
||||||
|
<label>Nudge interval (10–1000ms):</label>
|
||||||
|
<input type="text" class="site-subtitleNudgeInterval" placeholder="50" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-controlbar">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override in-player control bar for this site</span>
|
||||||
|
<input type="checkbox" class="override-controlbar" />
|
||||||
|
</label>
|
||||||
|
<div class="site-controlbar-container" style="display: none">
|
||||||
|
<div class="cb-editor">
|
||||||
|
<div class="cb-zone">
|
||||||
|
<div class="cb-zone-label">Active</div>
|
||||||
|
<div class="cb-dropzone cb-active-zone site-cb-active"></div>
|
||||||
|
</div>
|
||||||
|
<div class="cb-zone">
|
||||||
|
<div class="cb-zone-label">Available</div>
|
||||||
|
<div class="cb-dropzone cb-available-zone site-cb-available"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-controlbar">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override extension popup for this site</span>
|
||||||
|
<input type="checkbox" class="override-popup-controlbar" />
|
||||||
|
</label>
|
||||||
|
<div class="site-popup-controlbar-container" style="display: none">
|
||||||
|
<div class="site-rule-option site-rule-option-checkbox">
|
||||||
|
<label>Show popup control bar</label>
|
||||||
|
<input type="checkbox" class="site-showPopupControlBar" />
|
||||||
|
</div>
|
||||||
|
<div class="cb-editor">
|
||||||
|
<div class="cb-zone">
|
||||||
|
<div class="cb-zone-label">Active</div>
|
||||||
|
<div class="cb-dropzone cb-active-zone site-popup-cb-active"></div>
|
||||||
|
</div>
|
||||||
|
<div class="cb-zone">
|
||||||
|
<div class="cb-zone-label">Available</div>
|
||||||
|
<div class="cb-dropzone cb-available-zone site-popup-cb-available"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="site-rule-shortcuts">
|
||||||
|
<label class="site-override-lead">
|
||||||
|
<span>Override shortcuts for this site</span>
|
||||||
|
<input type="checkbox" class="override-shortcuts" />
|
||||||
|
</label>
|
||||||
|
<div class="site-shortcuts-container" style="display: none"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<h4>Extension controls not appearing?</h4>
|
<section class="settings-card action-card">
|
||||||
<p>
|
<div class="section-heading">
|
||||||
This extension is only compatible with HTML5 audio and video. If you
|
<h3>Actions</h3>
|
||||||
don't see the controls showing up, chances are you are viewing a Flash
|
<p class="section-intro">Save, restore, export, or import settings.</p>
|
||||||
content. If you want to confirm, try right-clicking on the content and
|
</div>
|
||||||
inspect the menu: if it mentions flash, then that's the issue. That
|
<div class="action-row">
|
||||||
said, <b>most sites will fallback to HTML5</b> if they detect that Flash
|
<button id="save">Save Changes</button>
|
||||||
is not available. You can try manually disabling Flash from the browser.
|
<button id="restore">Restore Defaults</button>
|
||||||
</p>
|
<button id="exportSettings">Export Settings</button>
|
||||||
|
<button id="importSettings">Import Settings</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="status" role="status" aria-live="polite"></div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="faq" class="settings-card info-card">
|
||||||
|
<h4>Extension controls not appearing?</h4>
|
||||||
|
<p>
|
||||||
|
This extension only works with HTML5 audio and video. If the
|
||||||
|
controls never appear, you may be looking at Flash content instead.
|
||||||
|
Right-click the player to check: if the menu mentions Flash, that
|
||||||
|
is the issue. Most sites will fall back to HTML5 when Flash is not
|
||||||
|
available, so disabling Flash in the browser can help.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<footer class="support-footer settings-card">
|
||||||
|
<p>
|
||||||
|
If Speeder has been useful, consider supporting its development via
|
||||||
|
<a
|
||||||
|
href="https://github.com/sponsors/SoPat712"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>GitHub Sponsor</a
|
||||||
|
>
|
||||||
|
or
|
||||||
|
<a
|
||||||
|
href="https://ko-fi.com/joshpatra"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>Ko-Fi</a
|
||||||
|
>.
|
||||||
|
</p>
|
||||||
|
</footer>
|
||||||
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1733
-255
@@ -1,38 +1,9 @@
|
|||||||
var regStrip = /^[\r\t\f\v ]+|[\r\t\f\v ]+$/gm;
|
var regStrip = /^[\r\t\f\v ]+|[\r\t\f\v ]+$/gm;
|
||||||
|
|
||||||
var tcDefaults = {
|
var keyBindings = [];
|
||||||
speed: 1.0, // default:
|
|
||||||
displayKeyCode: 86, // default: V
|
|
||||||
rememberSpeed: false, // default: false
|
|
||||||
audioBoolean: false, // default: false
|
|
||||||
startHidden: false, // default: false
|
|
||||||
forceLastSavedSpeed: 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
|
|
||||||
],
|
|
||||||
blacklist: `www.instagram.com
|
|
||||||
twitter.com
|
|
||||||
imgur.com
|
|
||||||
teams.microsoft.com
|
|
||||||
`.replace(regStrip, ""),
|
|
||||||
// ADDED: Nudge defaults
|
|
||||||
enableSubtitleNudge: true,
|
|
||||||
subtitleNudgeInterval: 25,
|
|
||||||
subtitleNudgeAmount: 0.001
|
|
||||||
};
|
|
||||||
|
|
||||||
var keyBindings = []; // This is populated during save/restore
|
|
||||||
|
|
||||||
var keyCodeAliases = {
|
var keyCodeAliases = {
|
||||||
/* ... same as your original ... */ 0: "null",
|
0: "null",
|
||||||
null: "null",
|
null: "null",
|
||||||
undefined: "null",
|
undefined: "null",
|
||||||
32: "Space",
|
32: "Space",
|
||||||
@@ -83,252 +54,1630 @@ var keyCodeAliases = {
|
|||||||
173: "-"
|
173: "-"
|
||||||
};
|
};
|
||||||
|
|
||||||
function recordKeyPress(e) {
|
var keyCodeToKey = {
|
||||||
/* ... same as your original ... */
|
32: " ",
|
||||||
if (
|
37: "ArrowLeft",
|
||||||
(e.keyCode >= 48 && e.keyCode <= 57) ||
|
38: "ArrowUp",
|
||||||
(e.keyCode >= 65 && e.keyCode <= 90) ||
|
39: "ArrowRight",
|
||||||
keyCodeAliases[e.keyCode]
|
40: "ArrowDown",
|
||||||
) {
|
96: "0",
|
||||||
e.target.value =
|
97: "1",
|
||||||
keyCodeAliases[e.keyCode] || String.fromCharCode(e.keyCode);
|
98: "2",
|
||||||
e.target.keyCode = e.keyCode;
|
99: "3",
|
||||||
e.preventDefault();
|
100: "4",
|
||||||
e.stopPropagation();
|
101: "5",
|
||||||
} else if (e.keyCode === 8) {
|
102: "6",
|
||||||
e.target.value = "";
|
103: "7",
|
||||||
} else if (e.keyCode === 27) {
|
104: "8",
|
||||||
e.target.value = "null";
|
105: "9",
|
||||||
e.target.keyCode = null;
|
106: "*",
|
||||||
}
|
107: "+",
|
||||||
}
|
109: "-",
|
||||||
function inputFilterNumbersOnly(e) {
|
110: ".",
|
||||||
/* ... same as your original ... */
|
111: "/",
|
||||||
var char = String.fromCharCode(e.keyCode);
|
112: "F1",
|
||||||
if (!/[\d\.]$/.test(char) || !/^\d+(\.\d*)?$/.test(e.target.value + char)) {
|
113: "F2",
|
||||||
e.preventDefault();
|
114: "F3",
|
||||||
e.stopPropagation();
|
115: "F4",
|
||||||
}
|
116: "F5",
|
||||||
}
|
117: "F6",
|
||||||
function inputFocus(e) {
|
118: "F7",
|
||||||
/* ... same as your original ... */ e.target.value = "";
|
119: "F8",
|
||||||
}
|
120: "F9",
|
||||||
function inputBlur(e) {
|
121: "F10",
|
||||||
/* ... same as your original ... */ e.target.value =
|
122: "F11",
|
||||||
keyCodeAliases[e.target.keyCode] || String.fromCharCode(e.target.keyCode);
|
123: "F12",
|
||||||
}
|
186: ";",
|
||||||
// function updateShortcutInputText(inputId, keyCode) { /* ... same as your original ... */ } // Not directly used in provided options.js logic flow
|
188: "<",
|
||||||
function updateCustomShortcutInputText(inputItem, keyCode) {
|
189: "-",
|
||||||
/* ... same as your original ... */ inputItem.value =
|
187: "+",
|
||||||
keyCodeAliases[keyCode] || String.fromCharCode(keyCode);
|
190: ">",
|
||||||
inputItem.keyCode = keyCode;
|
191: "/",
|
||||||
}
|
192: "~",
|
||||||
var customActionsNoValues = ["pause", "muted", "mark", "jump", "display"]; // Original
|
219: "[",
|
||||||
function add_shortcut() {
|
220: "\\",
|
||||||
/* ... same as your original ... */
|
221: "]",
|
||||||
var html = `<select class="customDo"><option value="slower">Decrease speed</option><option value="faster">Increase speed</option><option value="rewind">Rewind</option><option value="advance">Advance</option><option value="reset">Reset speed</option><option value="fast">Preferred speed</option><option value="muted">Mute</option><option value="pause">Pause</option><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 class="customForce"><option value="false">Do not disable website key bindings</option><option value="true">Disable website key bindings</option></select><button class="removeParent">X</button>`;
|
222: "'",
|
||||||
var div = document.createElement("div");
|
59: ";",
|
||||||
div.setAttribute("class", "row customs");
|
61: "+",
|
||||||
div.innerHTML = html;
|
173: "-"
|
||||||
var customs_element = document.getElementById("customs");
|
};
|
||||||
customs_element.insertBefore(
|
|
||||||
div,
|
var modifierKeys = new Set([
|
||||||
customs_element.children[customs_element.childElementCount - 1]
|
"Alt",
|
||||||
);
|
"AltGraph",
|
||||||
}
|
"Control",
|
||||||
function createKeyBindings(item) {
|
"Fn",
|
||||||
/* ... same as your original ... */
|
"Hyper",
|
||||||
const action = item.querySelector(".customDo").value;
|
"Meta",
|
||||||
const key = item.querySelector(".customKey").keyCode;
|
"OS",
|
||||||
const value = Number(item.querySelector(".customValue").value);
|
"Shift"
|
||||||
const force = item.querySelector(".customForce").value;
|
]);
|
||||||
const predefined = !!item.id;
|
|
||||||
keyBindings.push({
|
var displayKeyAliases = {
|
||||||
action: action,
|
" ": "Space",
|
||||||
key: key,
|
ArrowLeft: "Left",
|
||||||
value: value,
|
ArrowUp: "Up",
|
||||||
force: force,
|
ArrowRight: "Right",
|
||||||
predefined: predefined
|
ArrowDown: "Down"
|
||||||
|
};
|
||||||
|
var controllerLocations = [
|
||||||
|
"top-left",
|
||||||
|
"top-center",
|
||||||
|
"top-right",
|
||||||
|
"middle-right",
|
||||||
|
"bottom-right",
|
||||||
|
"bottom-center",
|
||||||
|
"bottom-left",
|
||||||
|
"middle-left"
|
||||||
|
];
|
||||||
|
|
||||||
|
var controllerButtonDefs = {
|
||||||
|
rewind: { icon: "\u00AB", name: "Rewind" },
|
||||||
|
slower: { icon: "\u2212", name: "Decrease speed" },
|
||||||
|
faster: { icon: "+", name: "Increase speed" },
|
||||||
|
advance: { icon: "\u00BB", name: "Advance" },
|
||||||
|
display: { icon: "\u00D7", name: "Close controller" },
|
||||||
|
reset: { icon: "\u21BB", name: "Reset speed" },
|
||||||
|
fast: { icon: "\u2605", name: "Preferred speed" },
|
||||||
|
nudge: { icon: "\u2713", name: "Subtitle nudge" },
|
||||||
|
settings: { icon: "\u2699", name: "Settings" },
|
||||||
|
pause: { icon: "\u23EF", name: "Pause / Play" },
|
||||||
|
muted: { icon: "M", name: "Mute / Unmute" },
|
||||||
|
mark: { icon: "\u2691", name: "Set marker" },
|
||||||
|
jump: { icon: "\u21E5", name: "Jump to marker" }
|
||||||
|
};
|
||||||
|
var popupExcludedButtonIds = new Set(["settings"]);
|
||||||
|
|
||||||
|
/** Lucide picker only — not control-bar blocks (chip uses subtitleNudgeOn/Off). */
|
||||||
|
var lucideSubtitleNudgeActionLabels = {
|
||||||
|
subtitleNudgeOn: "Subtitle nudge — enabled",
|
||||||
|
subtitleNudgeOff: "Subtitle nudge — disabled"
|
||||||
|
};
|
||||||
|
|
||||||
|
function sanitizePopupButtonOrder(buttonIds) {
|
||||||
|
if (!Array.isArray(buttonIds)) return [];
|
||||||
|
var seen = new Set();
|
||||||
|
return buttonIds.filter(function (id) {
|
||||||
|
if (!controllerButtonDefs[id] || popupExcludedButtonIds.has(id) || seen.has(id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
seen.add(id);
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function validate() {
|
|
||||||
/* ... same as your original ... */
|
/** Cached custom Lucide SVGs (mirrors chrome.storage.local customButtonIcons). */
|
||||||
var valid = true;
|
var customButtonIconsLive = {};
|
||||||
var status = document.getElementById("status");
|
|
||||||
document
|
function fillControlBarIconElement(icon, buttonId) {
|
||||||
.getElementById("blacklist")
|
if (!icon || !buttonId) return;
|
||||||
.value.split("\n")
|
var doc = icon.ownerDocument || document;
|
||||||
.forEach((match) => {
|
if (buttonId === "nudge") {
|
||||||
match = match.replace(regStrip, "");
|
vscClearElement(icon);
|
||||||
if (match.startsWith("/")) {
|
icon.className = "cb-icon cb-icon-nudge-pair";
|
||||||
try {
|
function nudgeChipMarkup(action) {
|
||||||
new RegExp(match);
|
var c = customButtonIconsLive[action];
|
||||||
} catch (err) {
|
if (c && c.svg) return c.svg;
|
||||||
status.textContent =
|
if (typeof vscIconSvgString === "function") {
|
||||||
"Error: Invalid blacklist regex: " + match + ". Unable to save";
|
return vscIconSvgString(action, 14) || "";
|
||||||
valid = false;
|
}
|
||||||
return;
|
return "";
|
||||||
|
}
|
||||||
|
function appendChip(action, stateKey) {
|
||||||
|
var sp = document.createElement("span");
|
||||||
|
sp.className = "cb-nudge-chip";
|
||||||
|
sp.setAttribute("data-nudge-state", stateKey);
|
||||||
|
var inner = nudgeChipMarkup(action);
|
||||||
|
if (inner) {
|
||||||
|
var wrap = vscCreateSvgWrap(doc, inner, "vsc-btn-icon");
|
||||||
|
if (wrap) {
|
||||||
|
sp.appendChild(wrap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
icon.appendChild(sp);
|
||||||
|
}
|
||||||
|
appendChip("subtitleNudgeOn", "on");
|
||||||
|
var sep = document.createElement("span");
|
||||||
|
sep.className = "cb-nudge-sep";
|
||||||
|
sep.textContent = "/";
|
||||||
|
icon.appendChild(sep);
|
||||||
|
appendChip("subtitleNudgeOff", "off");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
icon.className = "cb-icon";
|
||||||
|
var custom = customButtonIconsLive[buttonId];
|
||||||
|
if (custom && custom.svg) {
|
||||||
|
if (vscSetSvgContent(icon, custom.svg)) return;
|
||||||
|
}
|
||||||
|
if (typeof vscIconSvgString === "function") {
|
||||||
|
var svgHtml = vscIconSvgString(buttonId, 16);
|
||||||
|
if (svgHtml) {
|
||||||
|
if (vscSetSvgContent(icon, svgHtml)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vscClearElement(icon);
|
||||||
|
var def = controllerButtonDefs[buttonId];
|
||||||
|
icon.textContent = (def && def.icon) || "?";
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDefaultBinding(action, key, keyCode, value) {
|
||||||
|
return {
|
||||||
|
action: action,
|
||||||
|
key: key,
|
||||||
|
keyCode: keyCode,
|
||||||
|
value: value,
|
||||||
|
force: false,
|
||||||
|
predefined: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var tcDefaults = {
|
||||||
|
speed: 1.0,
|
||||||
|
lastSpeed: 1.0,
|
||||||
|
displayKeyCode: 86,
|
||||||
|
rememberSpeed: false,
|
||||||
|
audioBoolean: false,
|
||||||
|
startHidden: false,
|
||||||
|
hideWithYouTubeControls: false,
|
||||||
|
hideWithControls: false,
|
||||||
|
hideWithControlsTimer: 2.0,
|
||||||
|
controllerLocation: "top-left",
|
||||||
|
forceLastSavedSpeed: false,
|
||||||
|
enabled: true,
|
||||||
|
controllerOpacity: 0.3,
|
||||||
|
controllerMarginTop: 0,
|
||||||
|
controllerMarginRight: 0,
|
||||||
|
controllerMarginBottom: 65,
|
||||||
|
controllerMarginLeft: 0,
|
||||||
|
keyBindings: [
|
||||||
|
createDefaultBinding("display", "V", 86, 0),
|
||||||
|
createDefaultBinding("move", "P", 80, 0),
|
||||||
|
createDefaultBinding("slower", "S", 83, 0.1),
|
||||||
|
createDefaultBinding("faster", "D", 68, 0.1),
|
||||||
|
createDefaultBinding("rewind", "Z", 90, 10),
|
||||||
|
createDefaultBinding("advance", "X", 88, 10),
|
||||||
|
createDefaultBinding("reset", "R", 82, 1),
|
||||||
|
createDefaultBinding("fast", "G", 71, 1.8),
|
||||||
|
createDefaultBinding("toggleSubtitleNudge", "N", 78, 0)
|
||||||
|
],
|
||||||
|
siteRules: [
|
||||||
|
{
|
||||||
|
pattern: "/^https:\\/\\/(www\\.)?youtube\\.com\\/(?!shorts\\/).*/",
|
||||||
|
enabled: true,
|
||||||
|
enableSubtitleNudge: true,
|
||||||
|
subtitleNudgeInterval: 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: "/^https:\\/\\/(www\\.)?youtube\\.com\\/shorts\\/.*/",
|
||||||
|
enabled: true,
|
||||||
|
rememberSpeed: true,
|
||||||
|
controllerMarginTop: 60,
|
||||||
|
controllerMarginBottom: 85
|
||||||
|
}
|
||||||
|
],
|
||||||
|
controllerButtons: ["rewind", "slower", "faster", "advance", "display"],
|
||||||
|
showPopupControlBar: true,
|
||||||
|
popupMatchHoverControls: true,
|
||||||
|
popupControllerButtons: ["rewind", "slower", "faster", "advance", "display"],
|
||||||
|
enableSubtitleNudge: false,
|
||||||
|
subtitleNudgeInterval: 50,
|
||||||
|
subtitleNudgeAmount: 0.001
|
||||||
|
};
|
||||||
|
|
||||||
|
const actionLabels = {
|
||||||
|
display: "Show/hide controller",
|
||||||
|
move: "Move controller",
|
||||||
|
slower: "Decrease speed",
|
||||||
|
faster: "Increase speed",
|
||||||
|
rewind: "Rewind",
|
||||||
|
advance: "Advance",
|
||||||
|
reset: "Reset speed",
|
||||||
|
fast: "Preferred speed",
|
||||||
|
muted: "Mute",
|
||||||
|
pause: "Pause",
|
||||||
|
mark: "Set marker",
|
||||||
|
jump: "Jump to marker",
|
||||||
|
toggleSubtitleNudge: "Toggle subtitle nudge"
|
||||||
|
};
|
||||||
|
|
||||||
|
const speedBindingActions = ["slower", "faster", "fast"];
|
||||||
|
|
||||||
|
function formatSpeedBindingDisplay(action, value) {
|
||||||
|
if (!speedBindingActions.includes(action)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
var n = Number(value);
|
||||||
|
if (!isFinite(n)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return n.toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
const customActionsNoValues = [
|
||||||
|
"reset",
|
||||||
|
"display",
|
||||||
|
"move",
|
||||||
|
"muted",
|
||||||
|
"pause",
|
||||||
|
"mark",
|
||||||
|
"jump",
|
||||||
|
"toggleSubtitleNudge"
|
||||||
|
];
|
||||||
|
|
||||||
|
function refreshAddShortcutSelector() {
|
||||||
|
const selector = document.getElementById("addShortcutSelector");
|
||||||
|
if (!selector) return;
|
||||||
|
|
||||||
|
// Clear existing options except the first one
|
||||||
|
while (selector.options.length > 1) {
|
||||||
|
selector.remove(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find all currently used actions
|
||||||
|
const usedActions = new Set();
|
||||||
|
document.querySelectorAll(".shortcut-row").forEach((row) => {
|
||||||
|
const action = row.dataset.action;
|
||||||
|
if (action) {
|
||||||
|
usedActions.add(action);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add all unused actions
|
||||||
|
Object.keys(actionLabels).forEach((action) => {
|
||||||
|
if (!usedActions.has(action)) {
|
||||||
|
const option = document.createElement("option");
|
||||||
|
option.value = action;
|
||||||
|
option.text = actionLabels[action];
|
||||||
|
selector.appendChild(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// If no available actions, hide or disable the selector
|
||||||
|
if (selector.options.length === 1) {
|
||||||
|
selector.disabled = true;
|
||||||
|
selector.options[0].text = "All shortcuts added";
|
||||||
|
} else {
|
||||||
|
selector.disabled = false;
|
||||||
|
selector.options[0].text = "Add shortcut\u2026";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureDefaultBinding(storage, action, key, keyCode, value) {
|
||||||
|
if (storage.keyBindings.some((item) => item.action === action)) return;
|
||||||
|
|
||||||
|
storage.keyBindings.push(createDefaultBinding(action, key, keyCode, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeControllerLocation(location) {
|
||||||
|
if (controllerLocations.includes(location)) return location;
|
||||||
|
return tcDefaults.controllerLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clampMarginPxInput(el, fallback) {
|
||||||
|
var n = parseInt(el && el.value, 10);
|
||||||
|
if (!Number.isFinite(n)) return fallback;
|
||||||
|
return Math.min(200, Math.max(0, n));
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncSiteRuleField(ruleEl, rule, key, isCheckbox) {
|
||||||
|
var input = ruleEl.querySelector(".site-" + key);
|
||||||
|
if (!input) return;
|
||||||
|
var globalEl = document.getElementById(key);
|
||||||
|
var value;
|
||||||
|
if (rule && rule[key] !== undefined) {
|
||||||
|
value = rule[key];
|
||||||
|
} else if (globalEl) {
|
||||||
|
value = isCheckbox ? globalEl.checked : globalEl.value;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isCheckbox) input.checked = Boolean(value);
|
||||||
|
else input.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeBindingKey(key) {
|
||||||
|
if (typeof key !== "string" || key.length === 0) return null;
|
||||||
|
if (key === "Spacebar") return " ";
|
||||||
|
if (key === "Esc") return "Escape";
|
||||||
|
if (key.length === 1 && /[a-z]/i.test(key)) return key.toUpperCase();
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLegacyKeyCode(binding) {
|
||||||
|
if (!binding) return null;
|
||||||
|
if (Number.isInteger(binding.keyCode)) return binding.keyCode;
|
||||||
|
if (typeof binding.key === "number" && Number.isInteger(binding.key)) {
|
||||||
|
return binding.key;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function legacyKeyCodeToBinding(keyCode) {
|
||||||
|
if (!Number.isInteger(keyCode)) return null;
|
||||||
|
var normalizedKey = keyCodeToKey[keyCode];
|
||||||
|
if (!normalizedKey && keyCode >= 48 && keyCode <= 57) {
|
||||||
|
normalizedKey = String.fromCharCode(keyCode);
|
||||||
|
}
|
||||||
|
if (!normalizedKey && keyCode >= 65 && keyCode <= 90) {
|
||||||
|
normalizedKey = String.fromCharCode(keyCode);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
key: normalizeBindingKey(normalizedKey),
|
||||||
|
keyCode: keyCode,
|
||||||
|
code: null,
|
||||||
|
disabled: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDisabledBinding() {
|
||||||
|
return {
|
||||||
|
key: null,
|
||||||
|
keyCode: null,
|
||||||
|
code: null,
|
||||||
|
disabled: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeStoredBinding(binding, fallbackKeyCode) {
|
||||||
|
var fallbackBinding = legacyKeyCodeToBinding(fallbackKeyCode);
|
||||||
|
if (!binding) {
|
||||||
|
return fallbackBinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
binding.disabled === true ||
|
||||||
|
(binding.key === null &&
|
||||||
|
binding.keyCode === null &&
|
||||||
|
binding.code === null)
|
||||||
|
) {
|
||||||
|
return createDisabledBinding();
|
||||||
|
}
|
||||||
|
|
||||||
|
var normalized = {
|
||||||
|
key: null,
|
||||||
|
keyCode: null,
|
||||||
|
code:
|
||||||
|
typeof binding.code === "string" && binding.code.length > 0
|
||||||
|
? binding.code
|
||||||
|
: null,
|
||||||
|
disabled: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof binding.key === "string") {
|
||||||
|
normalized.key = normalizeBindingKey(binding.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
var legacyKeyCode = getLegacyKeyCode(binding);
|
||||||
|
if (Number.isInteger(legacyKeyCode)) {
|
||||||
|
var legacyBinding = legacyKeyCodeToBinding(legacyKeyCode);
|
||||||
|
if (legacyBinding) {
|
||||||
|
normalized.key = normalized.key || legacyBinding.key;
|
||||||
|
normalized.keyCode = legacyKeyCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Number.isInteger(binding.keyCode)) {
|
||||||
|
normalized.keyCode = binding.keyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!normalized.key && fallbackBinding) {
|
||||||
|
normalized.key = fallbackBinding.key;
|
||||||
|
if (normalized.keyCode === null) normalized.keyCode = fallbackBinding.keyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!normalized.key && !normalized.code && normalized.keyCode === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBindingLabel(binding) {
|
||||||
|
if (!binding) return "";
|
||||||
|
if (binding.disabled) return "";
|
||||||
|
if (binding.key) {
|
||||||
|
return displayKeyAliases[binding.key] || binding.key;
|
||||||
|
}
|
||||||
|
var legacyKeyCode = getLegacyKeyCode(binding);
|
||||||
|
if (keyCodeAliases[legacyKeyCode]) return keyCodeAliases[legacyKeyCode];
|
||||||
|
if (Number.isInteger(legacyKeyCode)) return String.fromCharCode(legacyKeyCode);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function setShortcutInputBinding(input, binding) {
|
||||||
|
input.vscBinding = binding ? Object.assign({}, binding) : null;
|
||||||
|
input.keyCode =
|
||||||
|
binding && Number.isInteger(binding.keyCode) ? binding.keyCode : null;
|
||||||
|
input.value = getBindingLabel(binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
function captureBindingFromEvent(event) {
|
||||||
|
var normalizedKey = normalizeBindingKey(event.key);
|
||||||
|
if (!normalizedKey || modifierKeys.has(normalizedKey)) return null;
|
||||||
|
return {
|
||||||
|
key: normalizedKey,
|
||||||
|
keyCode: Number.isInteger(event.keyCode) ? event.keyCode : null,
|
||||||
|
code: event.code || null,
|
||||||
|
disabled: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function recordKeyPress(event) {
|
||||||
|
if (event.key === "Tab") return;
|
||||||
|
|
||||||
|
if (event.key === "Backspace") {
|
||||||
|
setShortcutInputBinding(event.target, null);
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
setShortcutInputBinding(event.target, createDisabledBinding());
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var binding = captureBindingFromEvent(event);
|
||||||
|
if (!binding) return;
|
||||||
|
|
||||||
|
setShortcutInputBinding(event.target, binding);
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
function inputFilterNumbersOnly(event) {
|
||||||
|
var char = String.fromCharCode(event.keyCode);
|
||||||
|
if (
|
||||||
|
!/[\d\.]$/.test(char) ||
|
||||||
|
!/^\d+(\.\d*)?$/.test(event.target.value + char)
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function inputFocus(event) {
|
||||||
|
event.target.value = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function inputBlur(event) {
|
||||||
|
setShortcutInputBinding(event.target, event.target.vscBinding || null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCustomShortcutInputText(inputItem, bindingOrKeyCode) {
|
||||||
|
if (
|
||||||
|
bindingOrKeyCode &&
|
||||||
|
typeof bindingOrKeyCode === "object" &&
|
||||||
|
!Array.isArray(bindingOrKeyCode)
|
||||||
|
) {
|
||||||
|
setShortcutInputBinding(inputItem, bindingOrKeyCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setShortcutInputBinding(inputItem, legacyKeyCodeToBinding(bindingOrKeyCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
function appendSelectOptions(select, options) {
|
||||||
|
options.forEach(function (optionData) {
|
||||||
|
var option = document.createElement("option");
|
||||||
|
option.value = optionData.value;
|
||||||
|
option.textContent = optionData.label;
|
||||||
|
select.appendChild(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_shortcut(action, value) {
|
||||||
|
if (!action) return;
|
||||||
|
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.setAttribute("class", "shortcut-row customs");
|
||||||
|
div.dataset.action = action;
|
||||||
|
|
||||||
|
var actionLabel = document.createElement("div");
|
||||||
|
actionLabel.className = "shortcut-label";
|
||||||
|
actionLabel.textContent = actionLabels[action] || action;
|
||||||
|
|
||||||
|
var keyInput = document.createElement("input");
|
||||||
|
keyInput.className = "customKey";
|
||||||
|
keyInput.type = "text";
|
||||||
|
keyInput.placeholder = "press a key";
|
||||||
|
|
||||||
|
var valueInput = document.createElement("input");
|
||||||
|
valueInput.className = "customValue";
|
||||||
|
valueInput.type = "text";
|
||||||
|
valueInput.placeholder = "value";
|
||||||
|
if (customActionsNoValues.includes(action)) {
|
||||||
|
valueInput.value = "N/A";
|
||||||
|
valueInput.disabled = true;
|
||||||
|
} else {
|
||||||
|
valueInput.value = formatSpeedBindingDisplay(action, value || 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var removeButton = document.createElement("button");
|
||||||
|
removeButton.className = "removeParent";
|
||||||
|
removeButton.type = "button";
|
||||||
|
removeButton.textContent = "\u00d7";
|
||||||
|
|
||||||
|
div.appendChild(actionLabel);
|
||||||
|
div.appendChild(keyInput);
|
||||||
|
div.appendChild(valueInput);
|
||||||
|
div.appendChild(removeButton);
|
||||||
|
|
||||||
|
var customsElement = document.querySelector(".shortcuts-grid");
|
||||||
|
customsElement.appendChild(div);
|
||||||
|
|
||||||
|
refreshAddShortcutSelector();
|
||||||
|
}
|
||||||
|
|
||||||
|
function createKeyBindings(item) {
|
||||||
|
var action = item.dataset.action || item.querySelector(".customDo").value;
|
||||||
|
var input = item.querySelector(".customKey");
|
||||||
|
var valueInput = item.querySelector(".customValue");
|
||||||
|
var predefined = !!item.id;
|
||||||
|
var fallbackKeyCode =
|
||||||
|
predefined && action === "display"
|
||||||
|
? tcDefaults.displayKeyCode
|
||||||
|
: undefined;
|
||||||
|
var binding = normalizeStoredBinding(input.vscBinding, fallbackKeyCode);
|
||||||
|
|
||||||
|
if (!binding) {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
message: "Error: Shortcut for " + action + " is invalid. Unable to save"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
keyBindings.push({
|
||||||
|
action: action,
|
||||||
|
key: binding.key,
|
||||||
|
keyCode: binding.keyCode,
|
||||||
|
code: binding.code,
|
||||||
|
disabled: binding.disabled === true,
|
||||||
|
value: customActionsNoValues.includes(action)
|
||||||
|
? 0
|
||||||
|
: Number(valueInput.value),
|
||||||
|
force: false,
|
||||||
|
predefined: predefined
|
||||||
|
});
|
||||||
|
|
||||||
|
return { valid: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate() {
|
||||||
|
var valid = true;
|
||||||
|
var status = document.getElementById("status");
|
||||||
|
|
||||||
|
// Validate site rules patterns
|
||||||
|
document.querySelectorAll(".site-rule").forEach((ruleEl) => {
|
||||||
|
var pattern = ruleEl.querySelector(".site-pattern").value.trim();
|
||||||
|
if (pattern.length === 0) return;
|
||||||
|
|
||||||
|
if (pattern.startsWith("/")) {
|
||||||
|
try {
|
||||||
|
var lastSlash = pattern.lastIndexOf("/");
|
||||||
|
if (lastSlash > 0) {
|
||||||
|
new RegExp(pattern.substring(1, lastSlash), pattern.substring(lastSlash + 1));
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
status.textContent =
|
||||||
|
"Error: Invalid site rule regex: " + pattern + ". Unable to save";
|
||||||
|
valid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODIFIED: save_options to include nudge settings
|
|
||||||
function save_options() {
|
function save_options() {
|
||||||
if (validate() === false) return;
|
if (validate() === false) return;
|
||||||
|
|
||||||
keyBindings = []; // Reset global keyBindings before populating from DOM
|
keyBindings = [];
|
||||||
Array.from(document.querySelectorAll(".customs")).forEach((item) =>
|
var status = document.getElementById("status");
|
||||||
createKeyBindings(item)
|
var saveError = null;
|
||||||
|
|
||||||
|
// Collect shortcuts from the main shortcuts section (both default and custom)
|
||||||
|
Array.from(document.querySelectorAll("#customs .shortcut-row")).forEach((item) => {
|
||||||
|
if (saveError) return;
|
||||||
|
var result = createKeyBindings(item);
|
||||||
|
if (!result.valid) saveError = result.message;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (saveError) {
|
||||||
|
status.textContent = saveError;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var settings = {};
|
||||||
|
settings.rememberSpeed = document.getElementById("rememberSpeed").checked;
|
||||||
|
settings.forceLastSavedSpeed =
|
||||||
|
document.getElementById("forceLastSavedSpeed").checked;
|
||||||
|
settings.audioBoolean = document.getElementById("audioBoolean").checked;
|
||||||
|
settings.enabled = document.getElementById("enabled").checked;
|
||||||
|
settings.startHidden = document.getElementById("startHidden").checked;
|
||||||
|
settings.hideWithControls = document.getElementById("hideWithControls").checked;
|
||||||
|
settings.hideWithControlsTimer =
|
||||||
|
Math.min(15, Math.max(0.1, parseFloat(document.getElementById("hideWithControlsTimer").value) || tcDefaults.hideWithControlsTimer));
|
||||||
|
|
||||||
|
// Sync back to the legacy key if it exists, for backward compatibility
|
||||||
|
settings.hideWithYouTubeControls = settings.hideWithControls;
|
||||||
|
|
||||||
|
if (settings.hideWithControlsTimer < 0.1) settings.hideWithControlsTimer = 0.1;
|
||||||
|
if (settings.hideWithControlsTimer > 15) settings.hideWithControlsTimer = 15;
|
||||||
|
|
||||||
|
settings.controllerLocation = normalizeControllerLocation(
|
||||||
|
document.getElementById("controllerLocation").value
|
||||||
|
);
|
||||||
|
settings.controllerOpacity =
|
||||||
|
parseFloat(document.getElementById("controllerOpacity").value) ||
|
||||||
|
tcDefaults.controllerOpacity;
|
||||||
|
|
||||||
|
settings.controllerMarginTop = clampMarginPxInput(
|
||||||
|
document.getElementById("controllerMarginTop"),
|
||||||
|
tcDefaults.controllerMarginTop
|
||||||
|
);
|
||||||
|
settings.controllerMarginBottom = clampMarginPxInput(
|
||||||
|
document.getElementById("controllerMarginBottom"),
|
||||||
|
tcDefaults.controllerMarginBottom
|
||||||
);
|
);
|
||||||
|
|
||||||
var s = {}; // Object to hold all settings to be saved
|
settings.keyBindings = keyBindings;
|
||||||
s.rememberSpeed = document.getElementById("rememberSpeed").checked;
|
settings.enableSubtitleNudge =
|
||||||
s.forceLastSavedSpeed = document.getElementById(
|
document.getElementById("enableSubtitleNudge").checked;
|
||||||
"forceLastSavedSpeed"
|
settings.subtitleNudgeInterval =
|
||||||
).checked;
|
|
||||||
s.audioBoolean = document.getElementById("audioBoolean").checked;
|
|
||||||
s.enabled = document.getElementById("enabled").checked;
|
|
||||||
s.startHidden = document.getElementById("startHidden").checked;
|
|
||||||
s.controllerOpacity = document.getElementById("controllerOpacity").value;
|
|
||||||
s.blacklist = document
|
|
||||||
.getElementById("blacklist")
|
|
||||||
.value.replace(regStrip, "");
|
|
||||||
s.keyBindings = keyBindings; // Use the populated global keyBindings
|
|
||||||
|
|
||||||
// ADDED: Save nudge settings
|
|
||||||
s.enableSubtitleNudge = document.getElementById(
|
|
||||||
"enableSubtitleNudge"
|
|
||||||
).checked;
|
|
||||||
s.subtitleNudgeInterval =
|
|
||||||
parseInt(document.getElementById("subtitleNudgeInterval").value, 10) ||
|
parseInt(document.getElementById("subtitleNudgeInterval").value, 10) ||
|
||||||
tcDefaults.subtitleNudgeInterval;
|
tcDefaults.subtitleNudgeInterval;
|
||||||
s.subtitleNudgeAmount =
|
settings.subtitleNudgeAmount = tcDefaults.subtitleNudgeAmount;
|
||||||
parseFloat(document.getElementById("subtitleNudgeAmount").value) ||
|
|
||||||
tcDefaults.subtitleNudgeAmount;
|
|
||||||
// Basic validation for nudge interval and amount
|
|
||||||
if (s.subtitleNudgeInterval < 10) s.subtitleNudgeInterval = 10; // Min 10ms
|
|
||||||
if (s.subtitleNudgeAmount <= 0 || s.subtitleNudgeAmount > 0.1)
|
|
||||||
s.subtitleNudgeAmount = tcDefaults.subtitleNudgeAmount;
|
|
||||||
|
|
||||||
// Remove old flat settings (original logic)
|
if (settings.subtitleNudgeInterval < 10) {
|
||||||
chrome.storage.sync.remove([
|
settings.subtitleNudgeInterval = 10;
|
||||||
"resetSpeed",
|
}
|
||||||
"speedStep",
|
if (settings.subtitleNudgeInterval > 1000) {
|
||||||
"fastSpeed",
|
settings.subtitleNudgeInterval = 1000;
|
||||||
"rewindTime",
|
}
|
||||||
"advanceTime",
|
|
||||||
"resetKeyCode",
|
|
||||||
"slowerKeyCode",
|
|
||||||
"fasterKeyCode",
|
|
||||||
"rewindKeyCode",
|
|
||||||
"advanceKeyCode",
|
|
||||||
"fastKeyCode"
|
|
||||||
]);
|
|
||||||
|
|
||||||
chrome.storage.sync.set(s, function () {
|
settings.controllerButtons = getControlBarOrder();
|
||||||
var status = document.getElementById("status");
|
settings.showPopupControlBar =
|
||||||
status.textContent = "Options saved";
|
document.getElementById("showPopupControlBar").checked;
|
||||||
setTimeout(function () {
|
settings.popupMatchHoverControls =
|
||||||
status.textContent = "";
|
document.getElementById("popupMatchHoverControls").checked;
|
||||||
}, 1000);
|
settings.popupControllerButtons = sanitizePopupButtonOrder(getPopupControlBarOrder());
|
||||||
|
|
||||||
|
// Collect site rules
|
||||||
|
settings.siteRules = [];
|
||||||
|
document.querySelectorAll(".site-rule").forEach((ruleEl) => {
|
||||||
|
var pattern = ruleEl.querySelector(".site-pattern").value.trim();
|
||||||
|
if (pattern.length === 0) return;
|
||||||
|
|
||||||
|
var rule = { pattern: pattern };
|
||||||
|
|
||||||
|
// Handle Enable toggle
|
||||||
|
rule.enabled = ruleEl.querySelector(".site-enabled").checked;
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-placement").checked) {
|
||||||
|
rule.controllerLocation = normalizeControllerLocation(
|
||||||
|
ruleEl.querySelector(".site-controllerLocation").value
|
||||||
|
);
|
||||||
|
rule.controllerMarginTop = clampMarginPxInput(
|
||||||
|
ruleEl.querySelector(".site-controllerMarginTop"),
|
||||||
|
clampMarginPxInput(
|
||||||
|
document.getElementById("controllerMarginTop"),
|
||||||
|
tcDefaults.controllerMarginTop
|
||||||
|
)
|
||||||
|
);
|
||||||
|
rule.controllerMarginBottom = clampMarginPxInput(
|
||||||
|
ruleEl.querySelector(".site-controllerMarginBottom"),
|
||||||
|
clampMarginPxInput(
|
||||||
|
document.getElementById("controllerMarginBottom"),
|
||||||
|
tcDefaults.controllerMarginBottom
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-visibility").checked) {
|
||||||
|
rule.startHidden = ruleEl.querySelector(".site-startHidden").checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-autohide").checked) {
|
||||||
|
rule.hideWithControls = ruleEl.querySelector(".site-hideWithControls").checked;
|
||||||
|
var st = parseFloat(
|
||||||
|
ruleEl.querySelector(".site-hideWithControlsTimer").value
|
||||||
|
);
|
||||||
|
rule.hideWithControlsTimer = Math.min(
|
||||||
|
15,
|
||||||
|
Math.max(0.1, Number.isFinite(st) ? st : settings.hideWithControlsTimer)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-playback").checked) {
|
||||||
|
rule.rememberSpeed = ruleEl.querySelector(".site-rememberSpeed").checked;
|
||||||
|
rule.forceLastSavedSpeed =
|
||||||
|
ruleEl.querySelector(".site-forceLastSavedSpeed").checked;
|
||||||
|
rule.audioBoolean = ruleEl.querySelector(".site-audioBoolean").checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-opacity").checked) {
|
||||||
|
rule.controllerOpacity =
|
||||||
|
parseFloat(ruleEl.querySelector(".site-controllerOpacity").value) ||
|
||||||
|
settings.controllerOpacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-subtitleNudge").checked) {
|
||||||
|
rule.enableSubtitleNudge =
|
||||||
|
ruleEl.querySelector(".site-enableSubtitleNudge").checked;
|
||||||
|
var nudgeIv = parseInt(
|
||||||
|
ruleEl.querySelector(".site-subtitleNudgeInterval").value,
|
||||||
|
10
|
||||||
|
);
|
||||||
|
rule.subtitleNudgeInterval = Math.min(
|
||||||
|
1000,
|
||||||
|
Math.max(
|
||||||
|
10,
|
||||||
|
Number.isFinite(nudgeIv) ? nudgeIv : settings.subtitleNudgeInterval
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-controlbar").checked) {
|
||||||
|
var activeZone = ruleEl.querySelector(".site-cb-active");
|
||||||
|
if (activeZone) {
|
||||||
|
rule.controllerButtons = readControlBarOrder(activeZone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-popup-controlbar").checked) {
|
||||||
|
rule.showPopupControlBar =
|
||||||
|
ruleEl.querySelector(".site-showPopupControlBar").checked;
|
||||||
|
var popupActiveZone = ruleEl.querySelector(".site-popup-cb-active");
|
||||||
|
if (popupActiveZone) {
|
||||||
|
rule.popupControllerButtons = sanitizePopupButtonOrder(
|
||||||
|
readControlBarOrder(popupActiveZone)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleEl.querySelector(".override-shortcuts").checked) {
|
||||||
|
var shortcuts = [];
|
||||||
|
ruleEl.querySelectorAll(".site-shortcuts-container .customs").forEach((shortcutRow) => {
|
||||||
|
var action = shortcutRow.dataset.action;
|
||||||
|
var keyInput = shortcutRow.querySelector(".customKey");
|
||||||
|
var valueInput = shortcutRow.querySelector(".customValue");
|
||||||
|
var forceCheckbox = shortcutRow.querySelector(".customForce");
|
||||||
|
var binding = normalizeStoredBinding(keyInput.vscBinding);
|
||||||
|
|
||||||
|
if (binding) {
|
||||||
|
shortcuts.push({
|
||||||
|
action: action,
|
||||||
|
key: binding.key,
|
||||||
|
keyCode: binding.keyCode,
|
||||||
|
code: binding.code,
|
||||||
|
disabled: binding.disabled === true,
|
||||||
|
value: customActionsNoValues.includes(action)
|
||||||
|
? 0
|
||||||
|
: Number(valueInput.value),
|
||||||
|
force: forceCheckbox ? forceCheckbox.checked : false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (shortcuts.length > 0) rule.shortcuts = shortcuts;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.siteRules.push(rule);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Legacy keys to remove
|
||||||
|
const legacyKeys = [
|
||||||
|
"resetSpeed", "speedStep", "fastSpeed", "rewindTime", "advanceTime",
|
||||||
|
"resetKeyCode", "slowerKeyCode", "fasterKeyCode", "rewindKeyCode",
|
||||||
|
"advanceKeyCode", "fastKeyCode", "blacklist"
|
||||||
|
];
|
||||||
|
|
||||||
|
chrome.storage.sync.remove(legacyKeys, function () {
|
||||||
|
chrome.storage.sync.set(settings, function () {
|
||||||
|
status.textContent = "Options saved";
|
||||||
|
setTimeout(function () {
|
||||||
|
status.textContent = "";
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODIFIED: restore_options to include nudge settings
|
function ensureAllDefaultBindings(storage) {
|
||||||
|
tcDefaults.keyBindings.forEach((binding) => {
|
||||||
|
// Special case for "display" to support legacy displayKeyCode
|
||||||
|
if (binding.action === "display" && storage.displayKeyCode) {
|
||||||
|
ensureDefaultBinding(storage, "display", "V", storage.displayKeyCode, 0);
|
||||||
|
} else {
|
||||||
|
ensureDefaultBinding(
|
||||||
|
storage,
|
||||||
|
binding.action,
|
||||||
|
binding.key,
|
||||||
|
binding.keyCode,
|
||||||
|
binding.value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSiteRuleShortcut(container, action, binding, value, force) {
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.setAttribute("class", "shortcut-row customs");
|
||||||
|
div.dataset.action = action;
|
||||||
|
|
||||||
|
var actionLabel = document.createElement("div");
|
||||||
|
actionLabel.className = "shortcut-label";
|
||||||
|
var actionLabels = {
|
||||||
|
display: "Show/hide controller",
|
||||||
|
move: "Move controller",
|
||||||
|
slower: "Decrease speed",
|
||||||
|
faster: "Increase speed",
|
||||||
|
rewind: "Rewind",
|
||||||
|
advance: "Advance",
|
||||||
|
reset: "Reset speed",
|
||||||
|
fast: "Preferred speed",
|
||||||
|
muted: "Mute",
|
||||||
|
pause: "Pause",
|
||||||
|
mark: "Set marker",
|
||||||
|
jump: "Jump to marker",
|
||||||
|
toggleSubtitleNudge: "Toggle subtitle nudge"
|
||||||
|
};
|
||||||
|
var actionLabelText = actionLabels[action] || action;
|
||||||
|
if (action === "toggleSubtitleNudge") {
|
||||||
|
// Check if the site rule is for YouTube.
|
||||||
|
// We look up the pattern from the site rule element this container belongs to.
|
||||||
|
var ruleEl = container.closest(".site-rule");
|
||||||
|
var pattern = ruleEl ? ruleEl.querySelector(".site-pattern").value : "";
|
||||||
|
if (!pattern.toLowerCase().includes("youtube.com")) {
|
||||||
|
actionLabelText += " (only for YouTube embeds)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
actionLabel.textContent = actionLabelText;
|
||||||
|
|
||||||
|
var keyInput = document.createElement("input");
|
||||||
|
keyInput.className = "customKey";
|
||||||
|
keyInput.type = "text";
|
||||||
|
keyInput.placeholder = "press a key";
|
||||||
|
updateCustomShortcutInputText(keyInput, binding || createDisabledBinding());
|
||||||
|
|
||||||
|
var valueInput = document.createElement("input");
|
||||||
|
valueInput.className = "customValue";
|
||||||
|
valueInput.type = "text";
|
||||||
|
valueInput.placeholder = "value (0.10)";
|
||||||
|
if (customActionsNoValues.includes(action)) {
|
||||||
|
valueInput.value = "N/A";
|
||||||
|
valueInput.disabled = true;
|
||||||
|
} else {
|
||||||
|
valueInput.value = formatSpeedBindingDisplay(action, value || 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var forceLabel = document.createElement("label");
|
||||||
|
forceLabel.className = "force-label";
|
||||||
|
forceLabel.title = "Prevent website from capturing this key";
|
||||||
|
|
||||||
|
var forceCheckbox = document.createElement("input");
|
||||||
|
forceCheckbox.type = "checkbox";
|
||||||
|
forceCheckbox.className = "customForce";
|
||||||
|
forceCheckbox.checked = force === true || force === "true";
|
||||||
|
|
||||||
|
var forceText = document.createElement("span");
|
||||||
|
forceText.textContent = "Block site from capturing keypress";
|
||||||
|
forceText.className = "force-text";
|
||||||
|
|
||||||
|
forceLabel.appendChild(forceCheckbox);
|
||||||
|
forceLabel.appendChild(forceText);
|
||||||
|
|
||||||
|
div.appendChild(actionLabel);
|
||||||
|
div.appendChild(keyInput);
|
||||||
|
div.appendChild(valueInput);
|
||||||
|
div.appendChild(forceLabel);
|
||||||
|
|
||||||
|
container.appendChild(div);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createSiteRule(rule) {
|
||||||
|
var template = document.getElementById("siteRuleTemplate");
|
||||||
|
var clone = template.content.cloneNode(true);
|
||||||
|
var ruleEl = clone.querySelector(".site-rule");
|
||||||
|
|
||||||
|
var pattern = rule && rule.pattern ? rule.pattern : "";
|
||||||
|
ruleEl.querySelector(".site-pattern").value = pattern;
|
||||||
|
|
||||||
|
// Make the rule body collapsed by default
|
||||||
|
var ruleBody = ruleEl.querySelector(".site-rule-body");
|
||||||
|
ruleBody.style.display = "none";
|
||||||
|
ruleEl.classList.add("collapsed");
|
||||||
|
|
||||||
|
var enabledCheckbox = ruleEl.querySelector(".site-enabled");
|
||||||
|
var contentEl = ruleEl.querySelector(".site-rule-content");
|
||||||
|
|
||||||
|
function updateDisabledState() {
|
||||||
|
if (enabledCheckbox.checked) {
|
||||||
|
contentEl.classList.remove("disabled-rule");
|
||||||
|
} else {
|
||||||
|
contentEl.classList.add("disabled-rule");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enabledCheckbox.addEventListener("change", updateDisabledState);
|
||||||
|
|
||||||
|
if (rule) {
|
||||||
|
if (rule.enabled !== undefined) {
|
||||||
|
enabledCheckbox.checked = rule.enabled;
|
||||||
|
} else if (rule.disableExtension !== undefined) {
|
||||||
|
enabledCheckbox.checked = !rule.disableExtension;
|
||||||
|
} else {
|
||||||
|
enabledCheckbox.checked = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
enabledCheckbox.checked = true;
|
||||||
|
}
|
||||||
|
updateDisabledState();
|
||||||
|
|
||||||
|
var placementKeys = [
|
||||||
|
"controllerLocation",
|
||||||
|
"controllerMarginTop",
|
||||||
|
"controllerMarginBottom"
|
||||||
|
];
|
||||||
|
var hasPlacementOverride =
|
||||||
|
rule && placementKeys.some(function (k) { return rule[k] !== undefined; });
|
||||||
|
if (hasPlacementOverride) {
|
||||||
|
ruleEl.querySelector(".override-placement").checked = true;
|
||||||
|
ruleEl.querySelector(".site-placement-container").style.display = "block";
|
||||||
|
}
|
||||||
|
syncSiteRuleField(ruleEl, rule, "controllerLocation", false);
|
||||||
|
syncSiteRuleField(ruleEl, rule, "controllerMarginTop", false);
|
||||||
|
syncSiteRuleField(ruleEl, rule, "controllerMarginBottom", false);
|
||||||
|
|
||||||
|
if (rule && rule.startHidden !== undefined) {
|
||||||
|
ruleEl.querySelector(".override-visibility").checked = true;
|
||||||
|
ruleEl.querySelector(".site-visibility-container").style.display = "block";
|
||||||
|
}
|
||||||
|
syncSiteRuleField(ruleEl, rule, "startHidden", true);
|
||||||
|
|
||||||
|
if (
|
||||||
|
rule &&
|
||||||
|
(rule.hideWithControls !== undefined ||
|
||||||
|
rule.hideWithControlsTimer !== undefined)
|
||||||
|
) {
|
||||||
|
ruleEl.querySelector(".override-autohide").checked = true;
|
||||||
|
ruleEl.querySelector(".site-autohide-container").style.display = "block";
|
||||||
|
}
|
||||||
|
syncSiteRuleField(ruleEl, rule, "hideWithControls", true);
|
||||||
|
syncSiteRuleField(ruleEl, rule, "hideWithControlsTimer", false);
|
||||||
|
|
||||||
|
if (
|
||||||
|
rule &&
|
||||||
|
(rule.rememberSpeed !== undefined ||
|
||||||
|
rule.forceLastSavedSpeed !== undefined ||
|
||||||
|
rule.audioBoolean !== undefined)
|
||||||
|
) {
|
||||||
|
ruleEl.querySelector(".override-playback").checked = true;
|
||||||
|
ruleEl.querySelector(".site-playback-container").style.display = "block";
|
||||||
|
}
|
||||||
|
syncSiteRuleField(ruleEl, rule, "rememberSpeed", true);
|
||||||
|
syncSiteRuleField(ruleEl, rule, "forceLastSavedSpeed", true);
|
||||||
|
syncSiteRuleField(ruleEl, rule, "audioBoolean", true);
|
||||||
|
|
||||||
|
if (rule && rule.controllerOpacity !== undefined) {
|
||||||
|
ruleEl.querySelector(".override-opacity").checked = true;
|
||||||
|
ruleEl.querySelector(".site-opacity-container").style.display = "block";
|
||||||
|
}
|
||||||
|
syncSiteRuleField(ruleEl, rule, "controllerOpacity", false);
|
||||||
|
|
||||||
|
if (
|
||||||
|
rule &&
|
||||||
|
(rule.enableSubtitleNudge !== undefined ||
|
||||||
|
rule.subtitleNudgeInterval !== undefined)
|
||||||
|
) {
|
||||||
|
ruleEl.querySelector(".override-subtitleNudge").checked = true;
|
||||||
|
ruleEl.querySelector(".site-subtitleNudge-container").style.display =
|
||||||
|
"block";
|
||||||
|
}
|
||||||
|
syncSiteRuleField(ruleEl, rule, "enableSubtitleNudge", true);
|
||||||
|
syncSiteRuleField(ruleEl, rule, "subtitleNudgeInterval", false);
|
||||||
|
|
||||||
|
if (rule && Array.isArray(rule.controllerButtons)) {
|
||||||
|
ruleEl.querySelector(".override-controlbar").checked = true;
|
||||||
|
var cbContainer = ruleEl.querySelector(".site-controlbar-container");
|
||||||
|
cbContainer.style.display = "block";
|
||||||
|
populateControlBarZones(
|
||||||
|
ruleEl.querySelector(".site-cb-active"),
|
||||||
|
ruleEl.querySelector(".site-cb-available"),
|
||||||
|
rule.controllerButtons
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
rule &&
|
||||||
|
(rule.showPopupControlBar !== undefined ||
|
||||||
|
Array.isArray(rule.popupControllerButtons))
|
||||||
|
) {
|
||||||
|
ruleEl.querySelector(".override-popup-controlbar").checked = true;
|
||||||
|
var popupCbContainer = ruleEl.querySelector(".site-popup-controlbar-container");
|
||||||
|
popupCbContainer.style.display = "block";
|
||||||
|
var sitePopupActive = ruleEl.querySelector(".site-popup-cb-active");
|
||||||
|
var sitePopupAvailable = ruleEl.querySelector(".site-popup-cb-available");
|
||||||
|
if (Array.isArray(rule.popupControllerButtons)) {
|
||||||
|
populateControlBarZones(
|
||||||
|
sitePopupActive,
|
||||||
|
sitePopupAvailable,
|
||||||
|
sanitizePopupButtonOrder(rule.popupControllerButtons),
|
||||||
|
function (id) {
|
||||||
|
return !popupExcludedButtonIds.has(id);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
sitePopupActive &&
|
||||||
|
sitePopupAvailable &&
|
||||||
|
sitePopupActive.children.length === 0
|
||||||
|
) {
|
||||||
|
populateControlBarZones(
|
||||||
|
sitePopupActive,
|
||||||
|
sitePopupAvailable,
|
||||||
|
getPopupControlBarOrder(),
|
||||||
|
function (id) {
|
||||||
|
return !popupExcludedButtonIds.has(id);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
syncSiteRuleField(ruleEl, rule, "showPopupControlBar", true);
|
||||||
|
|
||||||
|
if (rule && Array.isArray(rule.shortcuts) && rule.shortcuts.length > 0) {
|
||||||
|
ruleEl.querySelector(".override-shortcuts").checked = true;
|
||||||
|
var container = ruleEl.querySelector(".site-shortcuts-container");
|
||||||
|
container.style.display = "block";
|
||||||
|
|
||||||
|
rule.shortcuts.forEach((shortcut) => {
|
||||||
|
addSiteRuleShortcut(
|
||||||
|
container,
|
||||||
|
shortcut.action,
|
||||||
|
shortcut,
|
||||||
|
shortcut.value,
|
||||||
|
shortcut.force
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("siteRulesContainer").appendChild(ruleEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateDefaultSiteShortcuts(container) {
|
||||||
|
tcDefaults.keyBindings.forEach((binding) => {
|
||||||
|
addSiteRuleShortcut(container, binding.action, binding, binding.value, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createControlBarBlock(buttonId) {
|
||||||
|
var def = controllerButtonDefs[buttonId];
|
||||||
|
if (!def) return null;
|
||||||
|
|
||||||
|
var block = document.createElement("div");
|
||||||
|
block.className = "cb-block";
|
||||||
|
block.dataset.buttonId = buttonId;
|
||||||
|
block.draggable = true;
|
||||||
|
|
||||||
|
var grip = document.createElement("span");
|
||||||
|
grip.className = "cb-grip";
|
||||||
|
|
||||||
|
var icon = document.createElement("span");
|
||||||
|
icon.className = "cb-icon";
|
||||||
|
fillControlBarIconElement(icon, buttonId);
|
||||||
|
|
||||||
|
var label = document.createElement("span");
|
||||||
|
label.className = "cb-label";
|
||||||
|
label.textContent = def.name;
|
||||||
|
|
||||||
|
block.appendChild(grip);
|
||||||
|
block.appendChild(icon);
|
||||||
|
block.appendChild(label);
|
||||||
|
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateControlBarZones(activeZone, availableZone, activeIds, allowButtonId) {
|
||||||
|
vscClearElement(activeZone);
|
||||||
|
vscClearElement(availableZone);
|
||||||
|
|
||||||
|
var allowed = function (id) {
|
||||||
|
if (!controllerButtonDefs[id]) return false;
|
||||||
|
return typeof allowButtonId === "function" ? Boolean(allowButtonId(id)) : true;
|
||||||
|
};
|
||||||
|
|
||||||
|
activeIds.forEach(function (id) {
|
||||||
|
if (!allowed(id)) return;
|
||||||
|
var block = createControlBarBlock(id);
|
||||||
|
if (block) activeZone.appendChild(block);
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.keys(controllerButtonDefs).forEach(function (id) {
|
||||||
|
if (!allowed(id)) return;
|
||||||
|
if (!activeIds.includes(id)) {
|
||||||
|
var block = createControlBarBlock(id);
|
||||||
|
if (block) availableZone.appendChild(block);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function readControlBarOrder(activeZone) {
|
||||||
|
var blocks = activeZone.querySelectorAll(".cb-block");
|
||||||
|
return Array.from(blocks).map(function (block) {
|
||||||
|
return block.dataset.buttonId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateControlBarEditor(activeIds) {
|
||||||
|
populateControlBarZones(
|
||||||
|
document.getElementById("controlBarActive"),
|
||||||
|
document.getElementById("controlBarAvailable"),
|
||||||
|
activeIds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getControlBarOrder() {
|
||||||
|
return readControlBarOrder(document.getElementById("controlBarActive"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function populatePopupControlBarEditor(activeIds) {
|
||||||
|
var popupActiveIds = sanitizePopupButtonOrder(activeIds);
|
||||||
|
populateControlBarZones(
|
||||||
|
document.getElementById("popupControlBarActive"),
|
||||||
|
document.getElementById("popupControlBarAvailable"),
|
||||||
|
popupActiveIds,
|
||||||
|
function (id) {
|
||||||
|
return !popupExcludedButtonIds.has(id);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPopupControlBarOrder() {
|
||||||
|
return sanitizePopupButtonOrder(
|
||||||
|
readControlBarOrder(document.getElementById("popupControlBarActive"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePopupEditorDisabledState() {
|
||||||
|
var checkbox = document.getElementById("popupMatchHoverControls");
|
||||||
|
var wrap = document.getElementById("popupCbEditorWrap");
|
||||||
|
if (!checkbox || !wrap) return;
|
||||||
|
if (checkbox.checked) {
|
||||||
|
wrap.classList.add("cb-editor-disabled");
|
||||||
|
} else {
|
||||||
|
wrap.classList.remove("cb-editor-disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDragAfterElement(container, x, y) {
|
||||||
|
var elements = Array.from(
|
||||||
|
container.querySelectorAll(".cb-block:not(.cb-dragging)")
|
||||||
|
);
|
||||||
|
|
||||||
|
for (var i = 0; i < elements.length; i++) {
|
||||||
|
var box = elements[i].getBoundingClientRect();
|
||||||
|
var centerX = box.left + box.width / 2;
|
||||||
|
var centerY = box.top + box.height / 2;
|
||||||
|
var rowThresh = box.height * 0.5;
|
||||||
|
|
||||||
|
if (y - centerY > rowThresh) continue;
|
||||||
|
if (centerY - y > rowThresh) return elements[i];
|
||||||
|
if (x < centerX) return elements[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initControlBarEditor() {
|
||||||
|
var draggedBlock = null;
|
||||||
|
|
||||||
|
function clearControlBarDropTargets(activeZone) {
|
||||||
|
document.querySelectorAll(".cb-dropzone.cb-over").forEach(function (zone) {
|
||||||
|
if (zone !== activeZone) {
|
||||||
|
zone.classList.remove("cb-over");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("dragstart", function (e) {
|
||||||
|
var block = e.target.closest(".cb-block");
|
||||||
|
if (!block) return;
|
||||||
|
draggedBlock = block;
|
||||||
|
e.dataTransfer.effectAllowed = "move";
|
||||||
|
e.dataTransfer.setData("text/plain", block.dataset.buttonId);
|
||||||
|
requestAnimationFrame(function () {
|
||||||
|
block.classList.add("cb-dragging");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("dragend", function (e) {
|
||||||
|
var block = e.target.closest(".cb-block");
|
||||||
|
if (!block) return;
|
||||||
|
block.classList.remove("cb-dragging");
|
||||||
|
draggedBlock = null;
|
||||||
|
clearControlBarDropTargets(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("dragover", function (e) {
|
||||||
|
var zone = e.target.closest(".cb-dropzone");
|
||||||
|
if (!zone) {
|
||||||
|
clearControlBarDropTargets(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
if (e.dataTransfer) {
|
||||||
|
e.dataTransfer.dropEffect = "move";
|
||||||
|
}
|
||||||
|
clearControlBarDropTargets(zone);
|
||||||
|
zone.classList.add("cb-over");
|
||||||
|
|
||||||
|
if (!draggedBlock) return;
|
||||||
|
|
||||||
|
var afterEl = getDragAfterElement(zone, e.clientX, e.clientY);
|
||||||
|
if (afterEl) {
|
||||||
|
zone.insertBefore(draggedBlock, afterEl);
|
||||||
|
} else {
|
||||||
|
zone.appendChild(draggedBlock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("drop", function (e) {
|
||||||
|
var zone = e.target.closest(".cb-dropzone");
|
||||||
|
if (zone) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
clearControlBarDropTargets(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var lucidePickerSelectedSlug = null;
|
||||||
|
var lucideSearchTimer = null;
|
||||||
|
|
||||||
|
function setLucideStatus(msg) {
|
||||||
|
var el = document.getElementById("lucideIconStatus");
|
||||||
|
if (el) el.textContent = msg || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function repaintAllCbIconsFromCustomMap() {
|
||||||
|
document.querySelectorAll(".cb-block .cb-icon").forEach(function (icon) {
|
||||||
|
var block = icon.closest(".cb-block");
|
||||||
|
if (!block) return;
|
||||||
|
fillControlBarIconElement(icon, block.dataset.buttonId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function persistCustomButtonIcons(map, callback) {
|
||||||
|
chrome.storage.local.set({ customButtonIcons: map }, function () {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
setLucideStatus(
|
||||||
|
"Could not save icons: " + chrome.runtime.lastError.message
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
customButtonIconsLive = map;
|
||||||
|
if (callback) callback();
|
||||||
|
repaintAllCbIconsFromCustomMap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initLucideButtonIconsUI() {
|
||||||
|
var actionSel = document.getElementById("lucideIconActionSelect");
|
||||||
|
var searchInput = document.getElementById("lucideIconSearch");
|
||||||
|
var resultsEl = document.getElementById("lucideIconResults");
|
||||||
|
var previewEl = document.getElementById("lucideIconPreview");
|
||||||
|
if (!actionSel || !searchInput || !resultsEl || !previewEl) return;
|
||||||
|
if (typeof getLucideTagsMap !== "function") return;
|
||||||
|
|
||||||
|
if (!actionSel.dataset.lucideInit) {
|
||||||
|
actionSel.dataset.lucideInit = "1";
|
||||||
|
vscClearElement(actionSel);
|
||||||
|
Object.keys(controllerButtonDefs).forEach(function (aid) {
|
||||||
|
if (aid === "nudge") {
|
||||||
|
Object.keys(lucideSubtitleNudgeActionLabels).forEach(function (subId) {
|
||||||
|
var o2 = document.createElement("option");
|
||||||
|
o2.value = subId;
|
||||||
|
o2.textContent =
|
||||||
|
lucideSubtitleNudgeActionLabels[subId] + " (" + subId + ")";
|
||||||
|
actionSel.appendChild(o2);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var o = document.createElement("option");
|
||||||
|
o.value = aid;
|
||||||
|
o.textContent =
|
||||||
|
controllerButtonDefs[aid].name + " (" + aid + ")";
|
||||||
|
actionSel.appendChild(o);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderResults(slugs) {
|
||||||
|
vscClearElement(resultsEl);
|
||||||
|
slugs.forEach(function (slug) {
|
||||||
|
var b = document.createElement("button");
|
||||||
|
b.type = "button";
|
||||||
|
b.className = "lucide-result-tile";
|
||||||
|
b.dataset.slug = slug;
|
||||||
|
b.title = slug;
|
||||||
|
b.setAttribute("aria-label", slug);
|
||||||
|
if (slug === lucidePickerSelectedSlug) {
|
||||||
|
b.classList.add("lucide-picked");
|
||||||
|
}
|
||||||
|
var url =
|
||||||
|
typeof lucideIconSvgUrl === "function" ? lucideIconSvgUrl(slug) : "";
|
||||||
|
if (url) {
|
||||||
|
var img = document.createElement("img");
|
||||||
|
img.className = "lucide-result-thumb";
|
||||||
|
img.src = url;
|
||||||
|
img.alt = "";
|
||||||
|
img.loading = "lazy";
|
||||||
|
b.appendChild(img);
|
||||||
|
} else {
|
||||||
|
b.textContent = slug.slice(0, 3);
|
||||||
|
}
|
||||||
|
b.addEventListener("click", function () {
|
||||||
|
lucidePickerSelectedSlug = slug;
|
||||||
|
Array.prototype.forEach.call(
|
||||||
|
resultsEl.querySelectorAll("button"),
|
||||||
|
function (x) {
|
||||||
|
x.classList.toggle("lucide-picked", x.dataset.slug === slug);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
fetchLucideSvg(slug)
|
||||||
|
.then(function (txt) {
|
||||||
|
var safe = sanitizeLucideSvg(txt);
|
||||||
|
if (!safe) throw new Error("Bad SVG");
|
||||||
|
if (!vscSetSvgContent(previewEl, safe)) {
|
||||||
|
throw new Error("Preview render failed");
|
||||||
|
}
|
||||||
|
setLucideStatus("Preview: " + slug);
|
||||||
|
})
|
||||||
|
.catch(function (e) {
|
||||||
|
vscClearElement(previewEl);
|
||||||
|
setLucideStatus(
|
||||||
|
"Could not load: " + slug + " — " + e.message
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
resultsEl.appendChild(b);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!searchInput.dataset.lucideBound) {
|
||||||
|
searchInput.dataset.lucideBound = "1";
|
||||||
|
searchInput.addEventListener("input", function () {
|
||||||
|
clearTimeout(lucideSearchTimer);
|
||||||
|
lucideSearchTimer = setTimeout(function () {
|
||||||
|
getLucideTagsMap(chrome.storage.local, false)
|
||||||
|
.then(function (map) {
|
||||||
|
var q = searchInput.value;
|
||||||
|
if (!q.trim()) {
|
||||||
|
vscClearElement(resultsEl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
renderResults(searchLucideSlugs(map, q, 48));
|
||||||
|
})
|
||||||
|
.catch(function (e) {
|
||||||
|
setLucideStatus("Icon list error: " + e.message);
|
||||||
|
});
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var applyBtn = document.getElementById("lucideIconApply");
|
||||||
|
if (applyBtn && !applyBtn.dataset.lucideBound) {
|
||||||
|
applyBtn.dataset.lucideBound = "1";
|
||||||
|
applyBtn.addEventListener("click", function () {
|
||||||
|
var action = actionSel.value;
|
||||||
|
var slug = lucidePickerSelectedSlug;
|
||||||
|
if (!action || !slug) {
|
||||||
|
setLucideStatus("Pick an action and click an icon first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fetchLucideSvg(slug)
|
||||||
|
.then(function (txt) {
|
||||||
|
var safe = sanitizeLucideSvg(txt);
|
||||||
|
if (!safe) throw new Error("Sanitize failed");
|
||||||
|
var next = Object.assign({}, customButtonIconsLive);
|
||||||
|
next[action] = { slug: slug, svg: safe };
|
||||||
|
persistCustomButtonIcons(next, function () {
|
||||||
|
setLucideStatus(
|
||||||
|
"Saved " +
|
||||||
|
slug +
|
||||||
|
" for " +
|
||||||
|
action +
|
||||||
|
". Reload pages for the hover bar."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function (e) {
|
||||||
|
setLucideStatus("Apply failed: " + e.message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var clrOne = document.getElementById("lucideIconClearAction");
|
||||||
|
if (clrOne && !clrOne.dataset.lucideBound) {
|
||||||
|
clrOne.dataset.lucideBound = "1";
|
||||||
|
clrOne.addEventListener("click", function () {
|
||||||
|
var action = actionSel.value;
|
||||||
|
if (!action) return;
|
||||||
|
var next = Object.assign({}, customButtonIconsLive);
|
||||||
|
delete next[action];
|
||||||
|
persistCustomButtonIcons(next, function () {
|
||||||
|
setLucideStatus("Cleared custom icon for " + action + ".");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var clrAll = document.getElementById("lucideIconClearAll");
|
||||||
|
if (clrAll && !clrAll.dataset.lucideBound) {
|
||||||
|
clrAll.dataset.lucideBound = "1";
|
||||||
|
clrAll.addEventListener("click", function () {
|
||||||
|
persistCustomButtonIcons({}, function () {
|
||||||
|
setLucideStatus("All custom icons cleared.");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var reloadTags = document.getElementById("lucideIconReloadTags");
|
||||||
|
if (reloadTags && !reloadTags.dataset.lucideBound) {
|
||||||
|
reloadTags.dataset.lucideBound = "1";
|
||||||
|
reloadTags.addEventListener("click", function () {
|
||||||
|
getLucideTagsMap(chrome.storage.local, true)
|
||||||
|
.then(function () {
|
||||||
|
setLucideStatus("Icon name list refreshed.");
|
||||||
|
})
|
||||||
|
.catch(function (e) {
|
||||||
|
setLucideStatus("Refresh failed: " + e.message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function restore_options() {
|
function restore_options() {
|
||||||
chrome.storage.sync.get(tcDefaults, function (storage) {
|
chrome.storage.sync.get(tcDefaults, function (storage) {
|
||||||
|
chrome.storage.local.get(["customButtonIcons"], function (loc) {
|
||||||
|
customButtonIconsLive =
|
||||||
|
loc && loc.customButtonIcons && typeof loc.customButtonIcons === "object"
|
||||||
|
? loc.customButtonIcons
|
||||||
|
: {};
|
||||||
|
|
||||||
document.getElementById("rememberSpeed").checked = storage.rememberSpeed;
|
document.getElementById("rememberSpeed").checked = storage.rememberSpeed;
|
||||||
document.getElementById("forceLastSavedSpeed").checked =
|
document.getElementById("forceLastSavedSpeed").checked =
|
||||||
storage.forceLastSavedSpeed;
|
storage.forceLastSavedSpeed;
|
||||||
document.getElementById("audioBoolean").checked = storage.audioBoolean;
|
document.getElementById("audioBoolean").checked = storage.audioBoolean;
|
||||||
document.getElementById("enabled").checked = storage.enabled;
|
document.getElementById("enabled").checked = storage.enabled;
|
||||||
document.getElementById("startHidden").checked = storage.startHidden;
|
document.getElementById("startHidden").checked = storage.startHidden;
|
||||||
|
|
||||||
|
// Migration/Normalization for hideWithControls
|
||||||
|
const hideWithControls = typeof storage.hideWithControls !== "undefined"
|
||||||
|
? storage.hideWithControls
|
||||||
|
: storage.hideWithYouTubeControls;
|
||||||
|
|
||||||
|
document.getElementById("hideWithControls").checked = hideWithControls;
|
||||||
|
document.getElementById("hideWithControlsTimer").value =
|
||||||
|
storage.hideWithControlsTimer || tcDefaults.hideWithControlsTimer;
|
||||||
|
|
||||||
|
document.getElementById("controllerLocation").value =
|
||||||
|
normalizeControllerLocation(storage.controllerLocation);
|
||||||
document.getElementById("controllerOpacity").value =
|
document.getElementById("controllerOpacity").value =
|
||||||
storage.controllerOpacity;
|
storage.controllerOpacity;
|
||||||
document.getElementById("blacklist").value = storage.blacklist;
|
document.getElementById("controllerMarginTop").value =
|
||||||
|
storage.controllerMarginTop ?? tcDefaults.controllerMarginTop;
|
||||||
// ADDED: Restore nudge settings
|
document.getElementById("controllerMarginBottom").value =
|
||||||
|
storage.controllerMarginBottom ?? tcDefaults.controllerMarginBottom;
|
||||||
|
document.getElementById("showPopupControlBar").checked =
|
||||||
|
storage.showPopupControlBar !== false;
|
||||||
document.getElementById("enableSubtitleNudge").checked =
|
document.getElementById("enableSubtitleNudge").checked =
|
||||||
storage.enableSubtitleNudge;
|
storage.enableSubtitleNudge;
|
||||||
document.getElementById("subtitleNudgeInterval").value =
|
document.getElementById("subtitleNudgeInterval").value =
|
||||||
storage.subtitleNudgeInterval;
|
storage.subtitleNudgeInterval;
|
||||||
document.getElementById("subtitleNudgeAmount").value =
|
|
||||||
storage.subtitleNudgeAmount;
|
|
||||||
|
|
||||||
// Original key binding restoration logic
|
if (!Array.isArray(storage.keyBindings) || storage.keyBindings.length === 0) {
|
||||||
if (
|
storage.keyBindings = tcDefaults.keyBindings.slice();
|
||||||
!Array.isArray(storage.keyBindings) ||
|
|
||||||
storage.keyBindings.length === 0
|
|
||||||
) {
|
|
||||||
// If keyBindings missing or not an array, use defaults from tcDefaults
|
|
||||||
storage.keyBindings = tcDefaults.keyBindings;
|
|
||||||
}
|
}
|
||||||
if (storage.keyBindings.filter((x) => x.action == "display").length == 0) {
|
|
||||||
storage.keyBindings.push({
|
ensureAllDefaultBindings(storage);
|
||||||
action: "display",
|
|
||||||
value: 0,
|
document.querySelectorAll(".customs:not([id])").forEach((row) => row.remove());
|
||||||
force: false,
|
|
||||||
predefined: true,
|
storage.keyBindings.forEach((item) => {
|
||||||
key: storage.displayKeyCode || tcDefaults.displayKeyCode
|
var row = document.getElementById(item.action);
|
||||||
|
var normalizedBinding = normalizeStoredBinding(item);
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
add_shortcut(item.action, item.value);
|
||||||
|
row = document.querySelector(".shortcut-row.customs:last-of-type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!row) return;
|
||||||
|
|
||||||
|
var keyInput = row.querySelector(".customKey");
|
||||||
|
if (keyInput) {
|
||||||
|
updateCustomShortcutInputText(keyInput, normalizedBinding || null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var valueInput = row.querySelector(".customValue");
|
||||||
|
if (customActionsNoValues.includes(item.action)) {
|
||||||
|
if (valueInput) {
|
||||||
|
valueInput.value = "N/A";
|
||||||
|
valueInput.disabled = true;
|
||||||
|
}
|
||||||
|
} else if (valueInput) {
|
||||||
|
valueInput.value = formatSpeedBindingDisplay(item.action, item.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshAddShortcutSelector();
|
||||||
|
|
||||||
|
// Load site rules (use defaults if none in storage or empty array)
|
||||||
|
var siteRules =
|
||||||
|
Array.isArray(storage.siteRules) && storage.siteRules.length > 0
|
||||||
|
? storage.siteRules
|
||||||
|
: tcDefaults.siteRules || [];
|
||||||
|
|
||||||
|
vscClearElement(document.getElementById("siteRulesContainer"));
|
||||||
|
if (siteRules.length > 0) {
|
||||||
|
siteRules.forEach((rule) => {
|
||||||
|
if (rule && rule.pattern) {
|
||||||
|
createSiteRule(rule);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear existing dynamic shortcuts before restoring (if any were added by mistake)
|
var controllerButtons = Array.isArray(storage.controllerButtons)
|
||||||
const dynamicShortcuts = document.querySelectorAll(".customs:not([id])");
|
? storage.controllerButtons
|
||||||
dynamicShortcuts.forEach((sc) => sc.remove());
|
: tcDefaults.controllerButtons;
|
||||||
|
populateControlBarEditor(controllerButtons);
|
||||||
|
|
||||||
for (let i in storage.keyBindings) {
|
document.getElementById("popupMatchHoverControls").checked =
|
||||||
var item = storage.keyBindings[i];
|
storage.popupMatchHoverControls !== false;
|
||||||
if (item.predefined) {
|
|
||||||
if (item["action"] == "display" && typeof item["key"] === "undefined") {
|
var popupButtons = Array.isArray(storage.popupControllerButtons)
|
||||||
item["key"] = storage.displayKeyCode || tcDefaults.displayKeyCode;
|
? storage.popupControllerButtons
|
||||||
}
|
: tcDefaults.popupControllerButtons;
|
||||||
if (customActionsNoValues.includes(item["action"])) {
|
populatePopupControlBarEditor(popupButtons);
|
||||||
const el = document.querySelector(
|
updatePopupEditorDisabledState();
|
||||||
"#" + item["action"] + " .customValue"
|
|
||||||
);
|
initLucideButtonIconsUI();
|
||||||
if (el) el.disabled = true;
|
});
|
||||||
}
|
|
||||||
const keyEl = document.querySelector(
|
|
||||||
"#" + item["action"] + " .customKey"
|
|
||||||
);
|
|
||||||
const valEl = document.querySelector(
|
|
||||||
"#" + item["action"] + " .customValue"
|
|
||||||
);
|
|
||||||
const forceEl = document.querySelector(
|
|
||||||
"#" + item["action"] + " .customForce"
|
|
||||||
);
|
|
||||||
if (keyEl) updateCustomShortcutInputText(keyEl, item["key"]);
|
|
||||||
if (valEl) valEl.value = item["value"];
|
|
||||||
if (forceEl) forceEl.value = String(item["force"]); // Ensure string for select value
|
|
||||||
} else {
|
|
||||||
// Non-predefined, dynamically added shortcuts
|
|
||||||
add_shortcut();
|
|
||||||
const dom = document.querySelector(".customs:last-of-type"); // Gets the newly added one
|
|
||||||
dom.querySelector(".customDo").value = item["action"];
|
|
||||||
if (customActionsNoValues.includes(item["action"])) {
|
|
||||||
dom.querySelector(".customValue").disabled = true;
|
|
||||||
}
|
|
||||||
updateCustomShortcutInputText(
|
|
||||||
dom.querySelector(".customKey"),
|
|
||||||
item["key"]
|
|
||||||
);
|
|
||||||
dom.querySelector(".customValue").value = item["value"];
|
|
||||||
dom.querySelector(".customForce").value = String(item["force"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_defaults() {
|
function restore_defaults() {
|
||||||
/* ... same as your original, tcDefaults now includes nudge defaults ... */
|
|
||||||
// Remove all dynamically added shortcuts first
|
|
||||||
document.querySelectorAll(".customs:not([id])").forEach((el) => el.remove());
|
document.querySelectorAll(".customs:not([id])").forEach((el) => el.remove());
|
||||||
// Then set defaults and restore options, which will re-add predefined ones correctly
|
|
||||||
|
chrome.storage.local.remove(
|
||||||
|
["customButtonIcons", "lucideTagsCacheV1", "lucideTagsCacheV1At"],
|
||||||
|
function () {}
|
||||||
|
);
|
||||||
|
|
||||||
chrome.storage.sync.set(tcDefaults, function () {
|
chrome.storage.sync.set(tcDefaults, function () {
|
||||||
restore_options(); // This will populate based on tcDefaults
|
restore_options();
|
||||||
var status = document.getElementById("status");
|
var status = document.getElementById("status");
|
||||||
status.textContent = "Default options restored";
|
status.textContent = "Default options restored";
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@@ -337,30 +1686,46 @@ function restore_defaults() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_experimental() {
|
|
||||||
/* ... same as your original ... */
|
|
||||||
document
|
|
||||||
.querySelectorAll(".customForce")
|
|
||||||
.forEach((item) => (item.style.display = "inline-block"));
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
/* ... same as your original event listeners setup ... */
|
var manifest = chrome.runtime.getManifest();
|
||||||
|
var versionElement = document.getElementById("app-version");
|
||||||
|
if (versionElement) {
|
||||||
|
versionElement.textContent = manifest.version;
|
||||||
|
}
|
||||||
|
|
||||||
restore_options();
|
restore_options();
|
||||||
|
initControlBarEditor();
|
||||||
|
|
||||||
|
document.getElementById("popupMatchHoverControls")
|
||||||
|
.addEventListener("change", updatePopupEditorDisabledState);
|
||||||
|
|
||||||
document.getElementById("save").addEventListener("click", save_options);
|
document.getElementById("save").addEventListener("click", save_options);
|
||||||
document.getElementById("add").addEventListener("click", add_shortcut);
|
|
||||||
|
const addSelector = document.getElementById("addShortcutSelector");
|
||||||
|
if (addSelector) {
|
||||||
|
addSelector.addEventListener("change", function (e) {
|
||||||
|
if (e.target.value) {
|
||||||
|
add_shortcut(e.target.value);
|
||||||
|
e.target.value = ""; // Reset selector
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
document
|
document
|
||||||
.getElementById("restore")
|
.getElementById("restore")
|
||||||
.addEventListener("click", restore_defaults);
|
.addEventListener("click", restore_defaults);
|
||||||
document
|
document
|
||||||
.getElementById("experimental")
|
.getElementById("addSiteRule")
|
||||||
.addEventListener("click", show_experimental);
|
.addEventListener("click", function () {
|
||||||
|
createSiteRule(null);
|
||||||
|
});
|
||||||
|
|
||||||
function eventCaller(event, className, funcName) {
|
function eventCaller(event, className, funcName) {
|
||||||
if (!event.target.classList || !event.target.classList.contains(className))
|
if (!event.target.classList || !event.target.classList.contains(className)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
funcName(event);
|
funcName(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("keypress", (event) =>
|
document.addEventListener("keypress", (event) =>
|
||||||
eventCaller(event, "customValue", inputFilterNumbersOnly)
|
eventCaller(event, "customValue", inputFilterNumbersOnly)
|
||||||
);
|
);
|
||||||
@@ -373,19 +1738,132 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
document.addEventListener("keydown", (event) =>
|
document.addEventListener("keydown", (event) =>
|
||||||
eventCaller(event, "customKey", recordKeyPress)
|
eventCaller(event, "customKey", recordKeyPress)
|
||||||
);
|
);
|
||||||
document.addEventListener("click", (event) =>
|
document.addEventListener("click", (event) => {
|
||||||
eventCaller(event, "removeParent", function () {
|
if (event.target.classList.contains("removeParent")) {
|
||||||
event.target.parentNode.remove();
|
event.target.parentNode.remove();
|
||||||
})
|
refreshAddShortcutSelector();
|
||||||
);
|
return;
|
||||||
document.addEventListener("change", (event) => {
|
}
|
||||||
eventCaller(event, "customDo", function () {
|
if (event.target.classList.contains("remove-site-rule")) {
|
||||||
if (customActionsNoValues.includes(event.target.value)) {
|
event.target.closest(".site-rule").remove();
|
||||||
event.target.nextElementSibling.nextElementSibling.disabled = true;
|
return;
|
||||||
event.target.nextElementSibling.nextElementSibling.value = 0; // Or "" if placeholder is preferred
|
}
|
||||||
|
if (event.target.classList.contains("toggle-site-rule")) {
|
||||||
|
var ruleEl = event.target.closest(".site-rule");
|
||||||
|
var ruleBody = ruleEl.querySelector(".site-rule-body");
|
||||||
|
var isCollapsed = ruleEl.classList.contains("collapsed");
|
||||||
|
|
||||||
|
if (isCollapsed) {
|
||||||
|
ruleBody.style.display = "block";
|
||||||
|
ruleEl.classList.remove("collapsed");
|
||||||
|
event.target.textContent = "\u2212";
|
||||||
} else {
|
} else {
|
||||||
event.target.nextElementSibling.nextElementSibling.disabled = false;
|
ruleBody.style.display = "none";
|
||||||
|
ruleEl.classList.add("collapsed");
|
||||||
|
event.target.textContent = "\u002b";
|
||||||
}
|
}
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.addEventListener("change", (event) => {
|
||||||
|
if (event.target.classList.contains("customDo")) {
|
||||||
|
var valueInput = event.target.nextElementSibling.nextElementSibling;
|
||||||
|
if (customActionsNoValues.includes(event.target.value)) {
|
||||||
|
valueInput.disabled = true;
|
||||||
|
valueInput.value = 0;
|
||||||
|
} else {
|
||||||
|
valueInput.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Site rule: show/hide optional override sections
|
||||||
|
var siteOverrideContainers = {
|
||||||
|
"override-placement": "site-placement-container",
|
||||||
|
"override-visibility": "site-visibility-container",
|
||||||
|
"override-autohide": "site-autohide-container",
|
||||||
|
"override-playback": "site-playback-container",
|
||||||
|
"override-opacity": "site-opacity-container",
|
||||||
|
"override-subtitleNudge": "site-subtitleNudge-container"
|
||||||
|
};
|
||||||
|
for (var ocb in siteOverrideContainers) {
|
||||||
|
if (event.target.classList.contains(ocb)) {
|
||||||
|
var siteRuleRoot = event.target.closest(".site-rule");
|
||||||
|
var targetBox = siteRuleRoot.querySelector(
|
||||||
|
"." + siteOverrideContainers[ocb]
|
||||||
|
);
|
||||||
|
if (targetBox) {
|
||||||
|
targetBox.style.display = event.target.checked ? "block" : "none";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle site rule override checkboxes
|
||||||
|
if (event.target.classList.contains("override-shortcuts")) {
|
||||||
|
var container = event.target
|
||||||
|
.closest(".site-rule-shortcuts")
|
||||||
|
.querySelector(".site-shortcuts-container");
|
||||||
|
if (event.target.checked) {
|
||||||
|
container.style.display = "block";
|
||||||
|
if (container.children.length === 0) {
|
||||||
|
populateDefaultSiteShortcuts(container);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
container.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.target.classList.contains("override-controlbar")) {
|
||||||
|
var cbContainer = event.target
|
||||||
|
.closest(".site-rule-controlbar")
|
||||||
|
.querySelector(".site-controlbar-container");
|
||||||
|
if (event.target.checked) {
|
||||||
|
cbContainer.style.display = "block";
|
||||||
|
var activeZone = cbContainer.querySelector(".site-cb-active");
|
||||||
|
var availableZone = cbContainer.querySelector(".site-cb-available");
|
||||||
|
if (
|
||||||
|
activeZone &&
|
||||||
|
availableZone &&
|
||||||
|
activeZone.children.length === 0 &&
|
||||||
|
availableZone.children.length === 0
|
||||||
|
) {
|
||||||
|
populateControlBarZones(
|
||||||
|
activeZone,
|
||||||
|
availableZone,
|
||||||
|
getControlBarOrder()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cbContainer.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.target.classList.contains("override-popup-controlbar")) {
|
||||||
|
var popupCbContainer = event.target
|
||||||
|
.closest(".site-rule-controlbar")
|
||||||
|
.querySelector(".site-popup-controlbar-container");
|
||||||
|
if (event.target.checked) {
|
||||||
|
popupCbContainer.style.display = "block";
|
||||||
|
var popupActiveZone = popupCbContainer.querySelector(".site-popup-cb-active");
|
||||||
|
var popupAvailableZone = popupCbContainer.querySelector(".site-popup-cb-available");
|
||||||
|
if (
|
||||||
|
popupActiveZone &&
|
||||||
|
popupAvailableZone &&
|
||||||
|
popupActiveZone.children.length === 0 &&
|
||||||
|
popupAvailableZone.children.length === 0
|
||||||
|
) {
|
||||||
|
populateControlBarZones(
|
||||||
|
popupActiveZone,
|
||||||
|
popupAvailableZone,
|
||||||
|
getPopupControlBarOrder(),
|
||||||
|
function (id) {
|
||||||
|
return !popupExcludedButtonIds.has(id);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
popupCbContainer.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,34 +1,269 @@
|
|||||||
body {
|
:root {
|
||||||
min-width: 8em;
|
--bg: #f4f5f7;
|
||||||
|
--panel: #ffffff;
|
||||||
|
--border: #e2e5e9;
|
||||||
|
--border-strong: #d4d9e0;
|
||||||
|
--text: #17191c;
|
||||||
|
--muted: #626b76;
|
||||||
|
--accent: #111827;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr {
|
* {
|
||||||
width: 100%;
|
box-sizing: border-box;
|
||||||
border: 0;
|
margin: 0;
|
||||||
height: 0;
|
padding: 0;
|
||||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
}
|
||||||
margin: 0.6em 0;
|
|
||||||
|
body {
|
||||||
|
min-width: 220px;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
font: 13px/1.45 "Avenir Next", "SF Pro Text", "Segoe UI", sans-serif;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-shell {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-title {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 15px;
|
||||||
|
font-family: "Avenir Next", "SF Pro Display", "Segoe UI", sans-serif;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-version {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--muted);
|
||||||
|
padding: 2px 7px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
appearance: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-image: linear-gradient(#ededed, #ededed 38%, #dedede);
|
min-height: 32px;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.25);
|
padding: 0 12px;
|
||||||
border-radius: 2px;
|
border: 1px solid var(--border-strong);
|
||||||
outline: none;
|
border-radius: 8px;
|
||||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08),
|
background: var(--panel);
|
||||||
inset 0 1px 2px rgba(255, 255, 255, 0.75);
|
color: var(--text);
|
||||||
color: #444;
|
|
||||||
text-shadow: 0 1px 0 rgb(240, 240, 240);
|
|
||||||
font: inherit;
|
font: inherit;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 120ms ease, border-color 120ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background: #f8f9fb;
|
||||||
|
border-color: #c5ccd5;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:active {
|
||||||
|
background: #f1f3f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:focus-visible {
|
||||||
|
outline: 2px solid rgba(17, 24, 39, 0.14);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#refresh {
|
||||||
|
background: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#refresh:hover {
|
||||||
|
background: #1f2937;
|
||||||
|
border-color: #1f2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: var(--border);
|
||||||
|
margin: 2px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-speed {
|
||||||
|
font-family: "Lucida Console", Monaco, monospace;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--text);
|
||||||
|
margin-right: 4px;
|
||||||
|
line-height: 1;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar button {
|
||||||
|
width: auto;
|
||||||
|
min-height: 24px;
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
font-family: "Lucida Console", Monaco, monospace;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 3px 7px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar button:hover {
|
||||||
|
background: var(--panel);
|
||||||
|
border-color: var(--border-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar button:active {
|
||||||
|
background: var(--bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar button.rw {
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar button.hideButton {
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar button .vsc-btn-icon {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
line-height: 0;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-control-bar button .vsc-btn-icon svg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-status {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: center;
|
||||||
|
padding: 2px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-links {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
padding-top: 8px;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-secondary {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.secondary {
|
.secondary {
|
||||||
font-size: 0.95em;
|
font-size: 12px;
|
||||||
margin: 0.15em 0;
|
min-height: 28px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.donate-wrap {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.donate-split {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.donate-split button {
|
||||||
|
width: auto;
|
||||||
|
border-radius: 0;
|
||||||
|
min-height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.donate-split button:first-child {
|
||||||
|
border-radius: 8px 0 0 8px;
|
||||||
|
border-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.donate-split button:last-child {
|
||||||
|
border-radius: 0 8px 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hide {
|
.hide {
|
||||||
display: none;
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg: #111315;
|
||||||
|
--panel: #171a1d;
|
||||||
|
--border: #2b3138;
|
||||||
|
--border-strong: #3a414a;
|
||||||
|
--text: #f2f4f6;
|
||||||
|
--muted: #a0a8b2;
|
||||||
|
--accent: #f2f4f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background: #1f2226;
|
||||||
|
border-color: #4a515a;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:active {
|
||||||
|
background: #252a2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#refresh {
|
||||||
|
background: #f2f4f6;
|
||||||
|
border-color: #f2f4f6;
|
||||||
|
color: #111315;
|
||||||
|
}
|
||||||
|
|
||||||
|
#refresh:hover {
|
||||||
|
background: #dfe3e8;
|
||||||
|
border-color: #dfe3e8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-10
@@ -1,18 +1,43 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Video Speed Controller: Popup</title>
|
<meta charset="utf-8" />
|
||||||
|
<title>Speeder</title>
|
||||||
<link rel="stylesheet" href="popup.css" />
|
<link rel="stylesheet" href="popup.css" />
|
||||||
|
<script src="ui-icons.js"></script>
|
||||||
<script src="popup.js"></script>
|
<script src="popup.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button id="enable" class="hide">Enable</button>
|
<div class="popup-shell">
|
||||||
<button id="disable">Disable</button>
|
<div class="popup-header">
|
||||||
<span id="status" class="hide"></span>
|
<span class="popup-title">Speeder</span>
|
||||||
<hr />
|
<span class="popup-version">v<span id="app-version"></span></span>
|
||||||
<button id="config">Settings</button>
|
</div>
|
||||||
<hr />
|
<div class="popup-actions">
|
||||||
<button id="feedback" class="secondary">Send feedback</button>
|
<button id="refresh">Rescan page for videos</button>
|
||||||
<button id="about" class="secondary">About</button>
|
<div class="popup-divider"></div>
|
||||||
|
<div id="popupControlBar" class="popup-control-bar">
|
||||||
|
<span id="popupSpeed" class="popup-speed">1.00</span>
|
||||||
|
</div>
|
||||||
|
<div class="popup-divider"></div>
|
||||||
|
<button id="enable" class="hide">Enable</button>
|
||||||
|
<button id="disable">Disable</button>
|
||||||
|
</div>
|
||||||
|
<div id="status" class="popup-status hide"></div>
|
||||||
|
<div class="popup-links">
|
||||||
|
<button id="config">Settings</button>
|
||||||
|
<div class="popup-secondary">
|
||||||
|
<button id="feedback" class="secondary">Feedback</button>
|
||||||
|
<button id="about" class="secondary">About</button>
|
||||||
|
</div>
|
||||||
|
<div id="donateWrap" class="donate-wrap">
|
||||||
|
<button id="donate" class="secondary">Donate</button>
|
||||||
|
<div id="donateOptions" class="donate-split hide">
|
||||||
|
<button id="donateKofi" class="secondary">Ko-fi</button>
|
||||||
|
<button id="donateGithub" class="secondary">Sponsors</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,14 +1,305 @@
|
|||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
var regStrip = /^[\r\t\f\v ]+|[\r\t\f\v ]+$/gm;
|
||||||
|
|
||||||
|
/* `label` is only used if ui-icons.js has no path for this action (fallback). */
|
||||||
|
var controllerButtonDefs = {
|
||||||
|
rewind: { label: "", className: "rw" },
|
||||||
|
slower: { label: "", className: "" },
|
||||||
|
faster: { label: "", className: "" },
|
||||||
|
advance: { label: "", className: "rw" },
|
||||||
|
display: { label: "", className: "hideButton" },
|
||||||
|
reset: { label: "\u21BB", className: "" },
|
||||||
|
fast: { label: "", className: "" },
|
||||||
|
nudge: { label: "", className: "" },
|
||||||
|
settings: { label: "", className: "" },
|
||||||
|
pause: { label: "", className: "" },
|
||||||
|
muted: { label: "", className: "" },
|
||||||
|
mark: { label: "", className: "" },
|
||||||
|
jump: { label: "", className: "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
var defaultButtons = ["rewind", "slower", "faster", "advance", "display"];
|
||||||
|
var popupExcludedButtonIds = new Set(["settings"]);
|
||||||
|
var storageDefaults = {
|
||||||
|
enabled: true,
|
||||||
|
showPopupControlBar: true,
|
||||||
|
controllerButtons: defaultButtons,
|
||||||
|
popupMatchHoverControls: true,
|
||||||
|
popupControllerButtons: defaultButtons,
|
||||||
|
siteRules: []
|
||||||
|
};
|
||||||
|
var renderToken = 0;
|
||||||
|
|
||||||
|
function escapeStringRegExp(str) {
|
||||||
|
const m = /[|\\{}()[\]^$+*?.]/g;
|
||||||
|
return str.replace(m, "\\$&");
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchSiteRule(url, siteRules) {
|
||||||
|
if (!url || !Array.isArray(siteRules)) return null;
|
||||||
|
for (var i = 0; i < siteRules.length; i++) {
|
||||||
|
var rule = siteRules[i];
|
||||||
|
if (!rule || !rule.pattern) continue;
|
||||||
|
var pattern = rule.pattern.replace(regStrip, "");
|
||||||
|
if (pattern.length === 0) continue;
|
||||||
|
var re;
|
||||||
|
if (pattern.startsWith("/") && pattern.lastIndexOf("/") > 0) {
|
||||||
|
try {
|
||||||
|
var ls = pattern.lastIndexOf("/");
|
||||||
|
re = new RegExp(pattern.substring(1, ls), pattern.substring(ls + 1));
|
||||||
|
} catch (e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
re = new RegExp(escapeStringRegExp(pattern));
|
||||||
|
}
|
||||||
|
if (re && re.test(url)) return rule;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSiteRuleDisabled(rule) {
|
||||||
|
return Boolean(
|
||||||
|
rule &&
|
||||||
|
(rule.enabled === false || rule.disableExtension === true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvePopupButtons(storage, siteRule) {
|
||||||
|
function sanitize(buttons) {
|
||||||
|
if (!Array.isArray(buttons)) return [];
|
||||||
|
var seen = new Set();
|
||||||
|
return buttons.filter(function (id) {
|
||||||
|
if (!controllerButtonDefs[id] || popupExcludedButtonIds.has(id) || seen.has(id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
seen.add(id);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (siteRule && Array.isArray(siteRule.popupControllerButtons)) {
|
||||||
|
return sanitize(siteRule.popupControllerButtons);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storage.popupMatchHoverControls) {
|
||||||
|
if (siteRule && Array.isArray(siteRule.controllerButtons)) {
|
||||||
|
return sanitize(siteRule.controllerButtons);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(storage.controllerButtons)) {
|
||||||
|
return sanitize(storage.controllerButtons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(storage.popupControllerButtons)) {
|
||||||
|
return sanitize(storage.popupControllerButtons);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sanitize(defaultButtons);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setControlBarVisible(visible) {
|
||||||
|
var bar = document.getElementById("popupControlBar");
|
||||||
|
var dividers = document.querySelectorAll(".popup-divider");
|
||||||
|
if (bar) bar.style.display = visible ? "" : "none";
|
||||||
|
dividers.forEach(function (d) { d.style.display = visible ? "" : "none"; });
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendToActiveTab(message, callback) {
|
||||||
|
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||||
|
if (tabs[0] && tabs[0].id) {
|
||||||
|
chrome.tabs.sendMessage(tabs[0].id, message, function (response) {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
if (callback) callback(null);
|
||||||
|
} else {
|
||||||
|
if (callback) callback(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (callback) callback(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActiveTabContext(callback) {
|
||||||
|
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||||
|
var activeTab = tabs && tabs[0] ? tabs[0] : null;
|
||||||
|
if (!activeTab || !activeTab.id) {
|
||||||
|
if (callback) callback({ tab: null, url: "" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tabUrl = typeof activeTab.url === "string" ? activeTab.url : "";
|
||||||
|
if (tabUrl.length > 0) {
|
||||||
|
if (callback) callback({ tab: activeTab, url: tabUrl });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.tabs.sendMessage(
|
||||||
|
activeTab.id,
|
||||||
|
{ action: "get_page_context" },
|
||||||
|
function (response) {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
if (callback) callback({ tab: activeTab, url: "" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pageUrl =
|
||||||
|
response && typeof response.url === "string" ? response.url : "";
|
||||||
|
if (callback) callback({ tab: activeTab, url: pageUrl });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSpeedDisplay(speed) {
|
||||||
|
var el = document.getElementById("popupSpeed");
|
||||||
|
if (el) el.textContent = (speed != null ? Number(speed) : 1).toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applySpeedAndResetFromResponse(response) {
|
||||||
|
if (response && response.speed != null) {
|
||||||
|
updateSpeedDisplay(response.speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickBestFrameSpeedResult(results) {
|
||||||
|
if (!results || !results.length) return null;
|
||||||
|
var i;
|
||||||
|
var r;
|
||||||
|
var fallback = null;
|
||||||
|
for (i = 0; i < results.length; i++) {
|
||||||
|
r = results[i];
|
||||||
|
if (!r || typeof r.speed !== "number") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (r.preferred) {
|
||||||
|
return { speed: r.speed };
|
||||||
|
}
|
||||||
|
if (!fallback) {
|
||||||
|
fallback = { speed: r.speed };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function querySpeed() {
|
||||||
|
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||||
|
if (!tabs[0] || tabs[0].id == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var tabId = tabs[0].id;
|
||||||
|
chrome.tabs.executeScript(
|
||||||
|
tabId,
|
||||||
|
{ allFrames: true, file: "frameSpeedSnapshot.js" },
|
||||||
|
function (results) {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
sendToActiveTab({ action: "get_speed" }, function (response) {
|
||||||
|
applySpeedAndResetFromResponse(response || { speed: 1 });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var best = pickBestFrameSpeedResult(results);
|
||||||
|
if (best) {
|
||||||
|
applySpeedAndResetFromResponse(best);
|
||||||
|
} else {
|
||||||
|
sendToActiveTab({ action: "get_speed" }, function (response) {
|
||||||
|
applySpeedAndResetFromResponse(response || { speed: 1 });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildControlBar(buttons, customIconsMap) {
|
||||||
|
var bar = document.getElementById("popupControlBar");
|
||||||
|
if (!bar) return;
|
||||||
|
|
||||||
|
var existing = bar.querySelectorAll("button");
|
||||||
|
existing.forEach(function (btn) { btn.remove(); });
|
||||||
|
|
||||||
|
var customMap = customIconsMap || {};
|
||||||
|
|
||||||
|
buttons.forEach(function (btnId) {
|
||||||
|
var def = controllerButtonDefs[btnId];
|
||||||
|
if (!def) return;
|
||||||
|
|
||||||
|
var btn = document.createElement("button");
|
||||||
|
btn.dataset.action = btnId;
|
||||||
|
var customEntry = customMap[btnId];
|
||||||
|
if (customEntry && customEntry.svg) {
|
||||||
|
var customSpan = vscCreateSvgWrap(document, customEntry.svg, "vsc-btn-icon");
|
||||||
|
if (customSpan) {
|
||||||
|
btn.appendChild(customSpan);
|
||||||
|
} else {
|
||||||
|
btn.textContent = def.label || "?";
|
||||||
|
}
|
||||||
|
} else if (typeof vscIconSvgString === "function") {
|
||||||
|
var svgStr = vscIconSvgString(btnId, 16);
|
||||||
|
if (svgStr) {
|
||||||
|
var iconSpan = vscCreateSvgWrap(document, svgStr, "vsc-btn-icon");
|
||||||
|
if (iconSpan) {
|
||||||
|
btn.appendChild(iconSpan);
|
||||||
|
} else {
|
||||||
|
btn.textContent = def.label || "?";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
btn.textContent = def.label || "?";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
btn.textContent = def.label || "?";
|
||||||
|
}
|
||||||
|
if (def.className) btn.className = def.className;
|
||||||
|
btn.title = btnId.charAt(0).toUpperCase() + btnId.slice(1);
|
||||||
|
|
||||||
|
btn.addEventListener("click", function () {
|
||||||
|
if (btnId === "settings") {
|
||||||
|
window.open(chrome.runtime.getURL("options.html"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendToActiveTab(
|
||||||
|
{ action: "run_action", actionName: btnId },
|
||||||
|
function () {
|
||||||
|
querySpeed();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
bar.appendChild(btn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var manifest = chrome.runtime.getManifest();
|
||||||
|
var versionElement = document.querySelector("#app-version");
|
||||||
|
if (versionElement) {
|
||||||
|
versionElement.innerText = manifest.version;
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelector("#config").addEventListener("click", function () {
|
document.querySelector("#config").addEventListener("click", function () {
|
||||||
window.open(chrome.runtime.getURL("options.html"));
|
window.open(chrome.runtime.getURL("options.html"));
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector("#about").addEventListener("click", function () {
|
document.querySelector("#about").addEventListener("click", function () {
|
||||||
window.open("https://github.com/codebicycle/videospeed");
|
window.open("https://github.com/SoPat712/Speeder");
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector("#feedback").addEventListener("click", function () {
|
document.querySelector("#feedback").addEventListener("click", function () {
|
||||||
window.open("https://github.com/codebicycle/videospeed/issues");
|
window.open("https://github.com/SoPat712/Speeder/issues");
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector("#donate").addEventListener("click", function () {
|
||||||
|
this.classList.add("hide");
|
||||||
|
document.querySelector("#donateOptions").classList.remove("hide");
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector("#donateKofi").addEventListener("click", function () {
|
||||||
|
window.open("https://ko-fi.com/joshpatra");
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector("#donateGithub").addEventListener("click", function () {
|
||||||
|
window.open("https://github.com/sponsors/SoPat712");
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector("#enable").addEventListener("click", function () {
|
document.querySelector("#enable").addEventListener("click", function () {
|
||||||
@@ -19,20 +310,106 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
toggleEnabled(false, settingsSavedReloadMessage);
|
toggleEnabled(false, settingsSavedReloadMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.sync.get({ enabled: true }, function (storage) {
|
document.querySelector("#refresh").addEventListener("click", function () {
|
||||||
toggleEnabledUI(storage.enabled);
|
setStatusMessage("Rescanning page...");
|
||||||
|
sendToActiveTab({ action: "rescan_page" }, function (response) {
|
||||||
|
if (!response) {
|
||||||
|
setStatusMessage("Cannot run on this page.");
|
||||||
|
} else if (response.status === "complete") {
|
||||||
|
setStatusMessage("Scan complete. Closing...");
|
||||||
|
setTimeout(function () { window.close(); }, 500);
|
||||||
|
} else {
|
||||||
|
setStatusMessage("Scan failed. Please reload the page.");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function renderForActiveTab() {
|
||||||
|
var currentRenderToken = ++renderToken;
|
||||||
|
|
||||||
|
chrome.storage.local.get(["customButtonIcons"], function (loc) {
|
||||||
|
if (currentRenderToken !== renderToken) return;
|
||||||
|
var customIconsMap =
|
||||||
|
loc && loc.customButtonIcons && typeof loc.customButtonIcons === "object"
|
||||||
|
? loc.customButtonIcons
|
||||||
|
: {};
|
||||||
|
|
||||||
|
chrome.storage.sync.get(storageDefaults, function (storage) {
|
||||||
|
if (currentRenderToken !== renderToken) return;
|
||||||
|
|
||||||
|
getActiveTabContext(function (context) {
|
||||||
|
if (currentRenderToken !== renderToken) return;
|
||||||
|
|
||||||
|
var url = context && context.url ? context.url : "";
|
||||||
|
var siteRule = matchSiteRule(url, storage.siteRules);
|
||||||
|
var siteDisabled = isSiteRuleDisabled(siteRule);
|
||||||
|
var siteAvailable = storage.enabled !== false && !siteDisabled;
|
||||||
|
var showBar = storage.showPopupControlBar !== false;
|
||||||
|
|
||||||
|
if (siteRule && siteRule.showPopupControlBar !== undefined) {
|
||||||
|
showBar = siteRule.showPopupControlBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleEnabledUI(storage.enabled !== false);
|
||||||
|
buildControlBar(
|
||||||
|
resolvePopupButtons(storage, siteRule),
|
||||||
|
customIconsMap
|
||||||
|
);
|
||||||
|
setControlBarVisible(siteAvailable && showBar);
|
||||||
|
|
||||||
|
if (siteDisabled) {
|
||||||
|
setStatusMessage("Speeder is disabled for this site.");
|
||||||
|
updateSpeedDisplay(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearStatusMessage();
|
||||||
|
if (siteAvailable) {
|
||||||
|
querySpeed();
|
||||||
|
} else {
|
||||||
|
updateSpeedDisplay(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.tabs.onActivated.addListener(function () {
|
||||||
|
renderForActiveTab();
|
||||||
|
});
|
||||||
|
|
||||||
|
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
|
||||||
|
if (!tab || tab.active !== true) return;
|
||||||
|
if (changeInfo.url !== undefined || changeInfo.status === "complete") {
|
||||||
|
renderForActiveTab();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
chrome.storage.onChanged.addListener(function (changes, areaName) {
|
||||||
|
if (areaName === "local" && changes.customButtonIcons) {
|
||||||
|
renderForActiveTab();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (areaName !== "sync") return;
|
||||||
|
if (
|
||||||
|
changes.enabled ||
|
||||||
|
changes.showPopupControlBar ||
|
||||||
|
changes.controllerButtons ||
|
||||||
|
changes.popupMatchHoverControls ||
|
||||||
|
changes.popupControllerButtons ||
|
||||||
|
changes.siteRules
|
||||||
|
) {
|
||||||
|
renderForActiveTab();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
renderForActiveTab();
|
||||||
|
|
||||||
function toggleEnabled(enabled, callback) {
|
function toggleEnabled(enabled, callback) {
|
||||||
chrome.storage.sync.set(
|
chrome.storage.sync.set({ enabled: enabled }, function () {
|
||||||
{
|
toggleEnabledUI(enabled);
|
||||||
enabled: enabled
|
if (callback) callback(enabled);
|
||||||
},
|
});
|
||||||
function () {
|
|
||||||
toggleEnabledUI(enabled);
|
|
||||||
if (callback) callback(enabled);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleEnabledUI(enabled) {
|
function toggleEnabledUI(enabled) {
|
||||||
@@ -42,9 +419,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
const suffix = `${enabled ? "" : "_disabled"}.png`;
|
const suffix = `${enabled ? "" : "_disabled"}.png`;
|
||||||
chrome.browserAction.setIcon({
|
chrome.browserAction.setIcon({
|
||||||
path: {
|
path: {
|
||||||
"19": "icons/icon19" + suffix,
|
19: "icons/icon19" + suffix,
|
||||||
"38": "icons/icon38" + suffix,
|
38: "icons/icon38" + suffix,
|
||||||
"48": "icons/icon48" + suffix
|
48: "icons/icon48" + suffix
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -60,4 +437,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
status_element.classList.toggle("hide", false);
|
status_element.classList.toggle("hide", false);
|
||||||
status_element.innerText = str;
|
status_element.innerText = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearStatusMessage() {
|
||||||
|
const status_element = document.querySelector("#status");
|
||||||
|
status_element.classList.toggle("hide", true);
|
||||||
|
status_element.innerText = "";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Executable
+98
@@ -0,0 +1,98 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Squash beta onto main, set manifest version, one release commit, push stable tag (v* without -beta).
|
||||||
|
# Does not merge dev or push to beta — promote only what is already on beta.
|
||||||
|
# Triggers .github/workflows/deploy.yml: listed AMO submission.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
manifest_version() {
|
||||||
|
python3 -c 'import json; print(json.load(open("manifest.json"))["version"])'
|
||||||
|
}
|
||||||
|
|
||||||
|
bump_manifest() {
|
||||||
|
local ver="$1"
|
||||||
|
VER="$ver" python3 <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
ver = os.environ["VER"]
|
||||||
|
path = "manifest.json"
|
||||||
|
with open(path, encoding="utf-8") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
data["version"] = ver
|
||||||
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(data, f, indent=2)
|
||||||
|
f.write("\n")
|
||||||
|
PY
|
||||||
|
}
|
||||||
|
|
||||||
|
normalize_semver() {
|
||||||
|
local s="$1"
|
||||||
|
s="${s#"${s%%[![:space:]]*}"}"
|
||||||
|
s="${s%"${s##*[![:space:]]}"}"
|
||||||
|
s="${s#v}"
|
||||||
|
s="${s#V}"
|
||||||
|
printf '%s' "$s"
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_semver() {
|
||||||
|
local s="$1"
|
||||||
|
if [[ -z "$s" ]]; then
|
||||||
|
echo "Error: empty version." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ! "$s" =~ ^[0-9]+(\.[0-9]+){0,3}(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
|
||||||
|
echo "Error: invalid version (use something like 5.0.4)." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n "$(git status --porcelain)" ]]; then
|
||||||
|
echo "Error: working tree is not clean. Commit or stash before releasing." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git checkout beta
|
||||||
|
git pull origin beta
|
||||||
|
|
||||||
|
echo "Current version on beta (manifest.json): $(manifest_version)"
|
||||||
|
read -r -p "Release version for manifest.json + tag (e.g. 5.0.4): " SEMVER_IN
|
||||||
|
SEMVER="$(normalize_semver "$SEMVER_IN")"
|
||||||
|
validate_semver "$SEMVER"
|
||||||
|
|
||||||
|
TAG="v${SEMVER}"
|
||||||
|
if [[ "$TAG" == *-beta* ]]; then
|
||||||
|
echo "Warning: stable tags should not contain '-beta' (workflow would use unlisted + prerelease, not AMO listed)."
|
||||||
|
read -r -p "Continue anyway? [y/N] " w
|
||||||
|
[[ "${w:-}" =~ ^[yY](es)?$ ]] || { echo "Aborted."; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "This will:"
|
||||||
|
echo " 1. checkout main, merge --squash origin/beta (single release commit on main)"
|
||||||
|
echo " 2. set manifest.json to $SEMVER in that commit (if anything else changed, it is included too)"
|
||||||
|
echo " 3. push origin main, create tag $TAG, push tag (triggers listed AMO submit)"
|
||||||
|
echo " 4. checkout dev (merge main→dev yourself if you want them aligned)"
|
||||||
|
read -r -p "Continue? [y/N] " confirm
|
||||||
|
[[ "${confirm:-}" =~ ^[yY](es)?$ ]] || { echo "Aborted."; exit 1; }
|
||||||
|
|
||||||
|
echo "🚀 Releasing stable $TAG to AMO (listed)"
|
||||||
|
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
git merge --squash beta
|
||||||
|
bump_manifest "$SEMVER"
|
||||||
|
git add -A
|
||||||
|
git commit -m "Release $TAG"
|
||||||
|
|
||||||
|
git push origin main
|
||||||
|
|
||||||
|
git tag -a "$TAG" -m "$TAG"
|
||||||
|
git push origin "$TAG"
|
||||||
|
|
||||||
|
git checkout dev
|
||||||
|
|
||||||
|
echo "✅ Done: main squashed from beta, tagged $TAG (manifest $SEMVER)"
|
||||||
Executable
+104
@@ -0,0 +1,104 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Merge dev → beta, push beta, and push an annotated beta tag (v*-beta*).
|
||||||
|
# Triggers .github/workflows/deploy.yml: unlisted AMO sign + GitHub prerelease.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
manifest_version() {
|
||||||
|
python3 -c 'import json; print(json.load(open("manifest.json"))["version"])'
|
||||||
|
}
|
||||||
|
|
||||||
|
bump_manifest() {
|
||||||
|
local ver="$1"
|
||||||
|
VER="$ver" python3 <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
ver = os.environ["VER"]
|
||||||
|
path = "manifest.json"
|
||||||
|
with open(path, encoding="utf-8") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
data["version"] = ver
|
||||||
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(data, f, indent=2)
|
||||||
|
f.write("\n")
|
||||||
|
PY
|
||||||
|
}
|
||||||
|
|
||||||
|
normalize_semver() {
|
||||||
|
local s="$1"
|
||||||
|
s="${s#"${s%%[![:space:]]*}"}"
|
||||||
|
s="${s%"${s##*[![:space:]]}"}"
|
||||||
|
s="${s#v}"
|
||||||
|
s="${s#V}"
|
||||||
|
printf '%s' "$s"
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_semver() {
|
||||||
|
local s="$1"
|
||||||
|
if [[ -z "$s" ]]; then
|
||||||
|
echo "Error: empty version." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ! "$s" =~ ^[0-9]+(\.[0-9]+){0,3}(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
|
||||||
|
echo "Error: invalid version (use something like 5.0.4 or 5.0.4-beta.1)." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n "$(git status --porcelain)" ]]; then
|
||||||
|
echo "Error: working tree is not clean. Commit or stash before releasing." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git checkout dev
|
||||||
|
git pull origin dev
|
||||||
|
|
||||||
|
echo "Current version in manifest.json: $(manifest_version)"
|
||||||
|
read -r -p "New version for manifest.json (e.g. 5.0.4): " SEMVER_IN
|
||||||
|
SEMVER="$(normalize_semver "$SEMVER_IN")"
|
||||||
|
validate_semver "$SEMVER"
|
||||||
|
|
||||||
|
echo "Beta git tag will include '-beta' (required by deploy.yml)."
|
||||||
|
read -r -p "Beta tag suffix [beta.1]: " SUFFIX_IN
|
||||||
|
SUFFIX="${SUFFIX_IN#"${SUFFIX_IN%%[![:space:]]*}"}"
|
||||||
|
SUFFIX="${SUFFIX%"${SUFFIX##*[![:space:]]}"}"
|
||||||
|
SUFFIX="${SUFFIX:-beta.1}"
|
||||||
|
|
||||||
|
TAG="v${SEMVER}-${SUFFIX}"
|
||||||
|
if [[ "$TAG" != *-beta* ]]; then
|
||||||
|
echo "Error: beta tag must contain '-beta' for the workflow (got $TAG). Try suffix like beta.1." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "This will:"
|
||||||
|
echo " 1. set manifest.json version to $SEMVER, commit on dev, push origin dev"
|
||||||
|
echo " 2. checkout beta, merge dev (no-ff), push origin beta"
|
||||||
|
echo " 3. create tag $TAG and push it (triggers beta AMO + prerelease)"
|
||||||
|
echo " 4. checkout dev (main is not modified)"
|
||||||
|
read -r -p "Continue? [y/N] " confirm
|
||||||
|
[[ "${confirm:-}" =~ ^[yY](es)?$ ]] || { echo "Aborted."; exit 1; }
|
||||||
|
|
||||||
|
echo "🚀 Releasing beta $TAG"
|
||||||
|
|
||||||
|
bump_manifest "$SEMVER"
|
||||||
|
git add manifest.json
|
||||||
|
git commit -m "Bump version to $SEMVER"
|
||||||
|
git push origin dev
|
||||||
|
|
||||||
|
git checkout beta
|
||||||
|
git pull origin beta
|
||||||
|
git merge dev --no-ff -m "$TAG"
|
||||||
|
git push origin beta
|
||||||
|
|
||||||
|
git tag -a "$TAG" -m "$TAG"
|
||||||
|
git push origin "$TAG"
|
||||||
|
|
||||||
|
git checkout dev
|
||||||
|
git pull origin dev
|
||||||
|
|
||||||
|
echo "✅ Done: beta $TAG (manifest $SEMVER; dev + beta + tag pushed)"
|
||||||
+216
-5
@@ -4,51 +4,222 @@
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Global * uses 1.9em line-height; without this, every node inside #controller
|
||||||
|
(including svg) keeps a tall line box and the bar grows + content rides high. */
|
||||||
|
#controller * {
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show extra buttons on hover or keyboard :focus-visible only. Plain :focus-within
|
||||||
|
after a mouse click kept #controls visible while hover-only rules (e.g. draggable
|
||||||
|
margin) turned off when the pointer left the bar. */
|
||||||
|
#controller:hover #controls,
|
||||||
|
#controller:focus-within:has(:focus-visible) #controls,
|
||||||
:host(:hover) #controls {
|
:host(:hover) #controls {
|
||||||
display: inline;
|
display: inline-flex;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#controller {
|
#controller {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
transform: translate(0, 0);
|
||||||
|
pointer-events: auto;
|
||||||
|
|
||||||
background: black;
|
background: black;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin: 10px 10px 10px 15px;
|
margin: 0;
|
||||||
|
|
||||||
cursor: default;
|
cursor: default;
|
||||||
z-index: 9999999;
|
/* Stay above the local video surface without overtaking page-level dialogs. */
|
||||||
|
z-index: 1;
|
||||||
|
transition: top 160ms ease, left 160ms ease, transform 160ms ease,
|
||||||
|
opacity 160ms ease;
|
||||||
|
/* Insets are baked into left/top; bar must not wrap when narrow. Hover controls
|
||||||
|
extend into the inset area (past “logical” margin). */
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: visible;
|
||||||
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#controller:hover {
|
#controller:hover {
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Space between speed readout and hover buttons — tweak this value (px) as you like */
|
||||||
#controller:hover > .draggable {
|
#controller:hover > .draggable {
|
||||||
margin-right: 0.8em;
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Center presets: midpoint between left- and right-preset inset lines; center bar on that X. */
|
||||||
|
#controller[data-location="top-center"]:not([data-position-mode="manual"]) {
|
||||||
|
transform: translate(-50%, 0) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#controller[data-location="bottom-center"]:not([data-position-mode="manual"]) {
|
||||||
|
transform: translate(-50%, -100%) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#controls {
|
#controls {
|
||||||
display: none;
|
display: none;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 3px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: visible;
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Standalone flash next to speed when N is pressed — hidden = no layout footprint */
|
||||||
|
#nudge-flash-indicator {
|
||||||
|
display: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
width: 0;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 0;
|
||||||
|
height: 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
vertical-align: middle;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: "Lucida Console", Monaco, monospace;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Same 24×24 footprint as #controls button */
|
||||||
|
#nudge-flash-indicator.visible {
|
||||||
|
display: inline-flex;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
min-width: 24px;
|
||||||
|
min-height: 24px;
|
||||||
|
max-width: 24px;
|
||||||
|
max-height: 24px;
|
||||||
|
margin-left: 5px;
|
||||||
|
padding: 0;
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-radius: 5px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 0;
|
||||||
|
line-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide flash indicator when hovering — the one in #controls is visible instead */
|
||||||
|
#controller:hover #nudge-flash-indicator,
|
||||||
|
:host(:hover) #nudge-flash-indicator {
|
||||||
|
display: none !important;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nudge-flash-indicator[data-enabled="true"] {
|
||||||
|
color: #fff;
|
||||||
|
background: #4b9135;
|
||||||
|
border-color: #6ec754;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nudge-flash-indicator[data-enabled="false"] {
|
||||||
|
color: #fff;
|
||||||
|
background: #943e3e;
|
||||||
|
border-color: #c06060;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Same 24×24 chip as control buttons (Lucide check / x inside) */
|
||||||
|
#nudge-indicator {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
min-width: 24px;
|
||||||
|
min-height: 24px;
|
||||||
|
max-height: 24px;
|
||||||
|
padding: 0;
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 0;
|
||||||
|
line-height: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
margin: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nudge-indicator[data-enabled="true"] {
|
||||||
|
color: #fff;
|
||||||
|
background: #4b9135;
|
||||||
|
border-color: #6ec754;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nudge-indicator[data-enabled="false"] {
|
||||||
|
color: #fff;
|
||||||
|
background: #943e3e;
|
||||||
|
border-color: #c06060;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nudge-indicator[data-supported="false"] {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nudge-flash-indicator.visible .vsc-btn-icon,
|
||||||
|
#nudge-indicator .vsc-btn-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nudge-flash-indicator.visible .vsc-btn-icon svg,
|
||||||
|
#nudge-indicator .vsc-btn-icon svg {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transform: translateY(0.5px);
|
||||||
}
|
}
|
||||||
|
|
||||||
#controller.dragging {
|
#controller.dragging {
|
||||||
cursor: -webkit-grabbing;
|
cursor: -webkit-grabbing;
|
||||||
cursor: -moz-grabbing;
|
cursor: -moz-grabbing;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
|
transition: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#controller.dragging #controls {
|
#controller.dragging #controls {
|
||||||
display: inline;
|
display: inline-flex;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.draggable {
|
.draggable {
|
||||||
cursor: -webkit-grab;
|
cursor: -webkit-grab;
|
||||||
cursor: -moz-grab;
|
cursor: -moz-grab;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.draggable:active {
|
.draggable:active {
|
||||||
@@ -70,6 +241,46 @@ button {
|
|||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Icon buttons: square targets, compact bar (no extra vertical stretch). */
|
||||||
|
#controls button {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
min-width: 24px;
|
||||||
|
min-height: 24px;
|
||||||
|
max-height: 24px;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
border-width: 1px;
|
||||||
|
line-height: 0;
|
||||||
|
font-size: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
button .vsc-btn-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
button .vsc-btn-icon svg {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
/* Lucide 24×24 paths sit slightly high in the viewBox */
|
||||||
|
transform: translateY(0.5px);
|
||||||
|
}
|
||||||
|
|
||||||
button:focus {
|
button:focus {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+140
@@ -0,0 +1,140 @@
|
|||||||
|
/**
|
||||||
|
* Inline SVG icons (Lucide-style strokes, compatible with https://lucide.dev — ISC license).
|
||||||
|
* Use stroke="currentColor" so buttons inherit foreground for monochrome UI.
|
||||||
|
*/
|
||||||
|
var VSC_ICON_SIZE_DEFAULT = 18;
|
||||||
|
var VSC_SVG_NS = "http://www.w3.org/2000/svg";
|
||||||
|
|
||||||
|
/** Inner SVG markup only (paths / shapes inside <svg>). */
|
||||||
|
var vscUiIconPaths = {
|
||||||
|
rewind:
|
||||||
|
'<polygon points="11 19 2 12 11 5 11 19"/><polygon points="22 19 13 12 22 5 22 19"/>',
|
||||||
|
advance:
|
||||||
|
'<polygon points="13 19 22 12 13 5 13 19"/><polygon points="2 19 11 12 2 5 2 19"/>',
|
||||||
|
reset:
|
||||||
|
'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/>',
|
||||||
|
slower: '<line x1="5" y1="12" x2="19" y2="12"/>',
|
||||||
|
faster:
|
||||||
|
'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',
|
||||||
|
display:
|
||||||
|
'<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>',
|
||||||
|
fast: '<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>',
|
||||||
|
settings:
|
||||||
|
'<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',
|
||||||
|
pause:
|
||||||
|
'<rect x="14" y="4" width="4" height="16" rx="1"/><rect x="6" y="4" width="4" height="16" rx="1"/>',
|
||||||
|
muted:
|
||||||
|
'<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/>',
|
||||||
|
mark: '<path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/>',
|
||||||
|
jump:
|
||||||
|
'<polyline points="9 10 4 15 9 20"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/>',
|
||||||
|
nudge: '<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>',
|
||||||
|
/** Lucide check — subtitle nudge on */
|
||||||
|
subtitleNudgeOn: '<path d="M20 6 9 17l-5-5"/>',
|
||||||
|
/** Lucide x — subtitle nudge off */
|
||||||
|
subtitleNudgeOff:
|
||||||
|
'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} [size] - width/height in px
|
||||||
|
* @returns {string} full <svg>…</svg>
|
||||||
|
*/
|
||||||
|
function vscIconSvgString(action, size) {
|
||||||
|
var inner = vscUiIconPaths[action];
|
||||||
|
if (!inner) return "";
|
||||||
|
var s = size != null ? size : VSC_ICON_SIZE_DEFAULT;
|
||||||
|
return (
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" width="' +
|
||||||
|
s +
|
||||||
|
'" height="' +
|
||||||
|
s +
|
||||||
|
'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' +
|
||||||
|
inner +
|
||||||
|
"</svg>"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function vscClearElement(el) {
|
||||||
|
if (!el) return;
|
||||||
|
while (el.firstChild) {
|
||||||
|
el.removeChild(el.firstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function vscSanitizeSvgTree(svg) {
|
||||||
|
if (!svg || String(svg.tagName).toLowerCase() !== "svg") return null;
|
||||||
|
|
||||||
|
svg.querySelectorAll("script, style, foreignObject").forEach(function (n) {
|
||||||
|
n.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.querySelectorAll("*").forEach(function (el) {
|
||||||
|
for (var i = el.attributes.length - 1; i >= 0; i--) {
|
||||||
|
var attr = el.attributes[i];
|
||||||
|
var name = attr.name.toLowerCase();
|
||||||
|
var val = attr.value;
|
||||||
|
if (name.indexOf("on") === 0) {
|
||||||
|
el.removeAttribute(attr.name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(name === "href" || name === "xlink:href") &&
|
||||||
|
/^\s*javascript:/i.test(val)
|
||||||
|
) {
|
||||||
|
el.removeAttribute(attr.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.setAttribute("xmlns", VSC_SVG_NS);
|
||||||
|
svg.setAttribute("aria-hidden", "true");
|
||||||
|
return svg;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vscCreateSvgNode(doc, svgText) {
|
||||||
|
if (!doc || !svgText || typeof svgText !== "string") return null;
|
||||||
|
var clean = String(svgText).replace(/\0/g, "").trim();
|
||||||
|
if (!clean || !/<svg[\s>]/i.test(clean)) return null;
|
||||||
|
|
||||||
|
var parsed = new DOMParser().parseFromString(clean, "image/svg+xml");
|
||||||
|
if (parsed.querySelector("parsererror")) return null;
|
||||||
|
|
||||||
|
var svg = vscSanitizeSvgTree(parsed.querySelector("svg"));
|
||||||
|
if (!svg) return null;
|
||||||
|
|
||||||
|
return doc.importNode(svg, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function vscSetSvgContent(el, svgText) {
|
||||||
|
if (!el) return false;
|
||||||
|
vscClearElement(el);
|
||||||
|
|
||||||
|
var doc = el.ownerDocument || document;
|
||||||
|
var svg = vscCreateSvgNode(doc, svgText);
|
||||||
|
if (!svg) return false;
|
||||||
|
|
||||||
|
el.appendChild(svg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vscCreateSvgWrap(doc, svgText, className) {
|
||||||
|
if (!doc) return null;
|
||||||
|
var span = doc.createElement("span");
|
||||||
|
span.className = className || "vsc-btn-icon";
|
||||||
|
if (!vscSetSvgContent(span, svgText)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return span;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Document} doc
|
||||||
|
* @param {string} action
|
||||||
|
* @returns {HTMLElement|null} wrapper span containing svg, or null if no icon
|
||||||
|
*/
|
||||||
|
function vscIconWrap(doc, action, size) {
|
||||||
|
var html = vscIconSvgString(action, size);
|
||||||
|
if (!html) return null;
|
||||||
|
return vscCreateSvgWrap(doc, html, "vsc-btn-icon");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user