Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ Today adding features can be easier & so motivating as there are 500 000 users.

<h2><a href="https://github.com/code-for-charity/ImprovedTube-for-YouTube/wiki/Contributing">Contributing</a></h2>
For more info on how to contribute, see the <a href="https://github.com/code-for-charity/ImprovedTube-for-YouTube/wiki/Contributing">contribution wiki</a> or <a href="https://github.com/code-charity/youtube/wiki/Contributing#development"> #development</a>
<br><br><i> Please join us! And let's re-define "<a href="https://en.wikipedia.org/wiki/Browser_extension">extensions</a>"!
(Why are they often unfunded & neglected?</i>)
<br><br> Please join us! Let's redefine "<a href="https://en.wikipedia.org/wiki/Browser_extension">Browser extensions</a>"!

<table align="right"><tr><td><h3><a href="https://github.com/code-charity/youtube/labels?sort=count-desc"><code>🏷️</code></a>Roadmap</h3> <!-- The list below only stays formatted when there is a line break above -->

Expand Down Expand Up @@ -207,9 +206,12 @@ Chinese + Hindi + Spanish. <br></i>
</td></tr></table><hr>

#### 💡 [**<code>History Manager Extension</code>**](https://chrome.google.com/webstore/detail/unblob-alpha/odognhgojidbcgconbcipmgffjcmfaoj)<a href="https://github.com/code-for-charity/history-manager"><img src="github.png" width="20px" height="18px"></a>
#### 💡 [<code>github/**Wish-Factory**</code>](https://github.com/code-for-charity/wish-factory "💡") Got great/er ideas? ( ideas@improvedtube.com )
##### 💡 [<img src="github.png" width="20px" height="18px"><code>**Crowd Fixes**</code>](https://github.com/code-charity/Universal-UserTweaks) - Vision for the _(tweaking-/userStyle-/"modding-"_)Community: We can optimize the www's GUI and greatly prioritized. <i>"insteada only tweakin uBlockRules @home like Sisyphos".</i>
#### 💡 🌱 [`Contributor Bot`](https://github.com/code4charity/Open-Source-Bot--Github-Git-Pull-Request-Bot) - Vision for Open-Source Efficiency. (Compare: Wikipedia Bots. Would especially help medium-size projects.) (+[list of regEx](https://github.com/code4charity/the-RegEx-Collector--Queries--Patterns " - ")?)
### 💡 🌱 [List of new project plans / Ideas ](https://github.com/code-charity/List-of-Ideas/discussions/2)
[<code>Wish-Factory</code>](https://github.com/code-for-charity/wish-factory "💡") Got great/er ideas? ideas@improvedtube.com

[<code>Crowd Fixes</code>](https://github.com/code-charity/Universal-UserTweaks) - Vision for the _(tweaking-/userStyle-/"modding-"_)Community: We can optimize the www's GUI and greatly prioritized. <i>"insteada only tweakin uBlockRules @home like Sisyphos".</i>

[`Contributor Bot`](https://github.com/code4charity/Open-Source-Bot--Github-Git-Pull-Request-Bot) - Vision for Open-Source Efficiency. (Compare: Wikipedia Bots. Would especially help medium-size projects.) (+[list of regEx](https://github.com/code4charity/the-RegEx-Collector--Queries--Patterns " - ")?)

<h4> <code>🎁</code>Our Extensions:</h4></summary>

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
109 changes: 109 additions & 0 deletions TEST_FIREFOX_SHORTCUTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Firefox Shortcuts Bug Fix - Test Guide

## What Was Fixed

**Problem:** Keyboard shortcuts didn't work when the video player wasn't in focus on Firefox.

**Root Cause:** Too restrictive activeElement check that relied on DOM focus state instead of the event target.

**Solution Applied:**
1. Changed event listener check to prioritize `event.target` over `document.activeElement`
2. Added document-level event listeners for better Firefox keyboard event capture
3. Improved conditional logic to only block shortcuts when actually typing

---

## How to Test

### Prerequisites
- Firefox or Floorp browser
- ImprovedTube extension loaded
- YouTube video open

### Test Steps

1. **Open Extension Settings**
- Click ImprovedTube icon → Settings
- Go to: **Shortcuts** section

2. **Configure Test Shortcuts**
- Set "Increase Volume" to `UP ARROW` key
- Set "Decrease Volume" to `DOWN ARROW` key
- Click Save

3. **Test 1: Player Focused (Should work before and after fix)**
- Click on the video player
- Press `UP ARROW` → Volume should increase ✓
- Press `DOWN ARROW` → Volume should decrease ✓

4. **Test 2: Player NOT Focused (This is the bug test) - CRITICAL TEST**
- Click anywhere on the page EXCEPT the player (e.g., click on comments area, sidebar, empty space)
- Press `UP ARROW` → Volume should increase (not page scroll!) ✓
- Press `DOWN ARROW` → Volume should decrease (not page scroll!) ✓
- The page should NOT scroll up/down

5. **Test 3: Safety Check - Shortcuts should NOT work in input fields**
- Open the search box (click search field)
- Press `UP ARROW` → Should just type in search, NOT change volume ✓

### Expected Results After Fix

| Scenario | Expected Behavior | Status |
|----------|------------------|--------|
| Player focused + shortcut key | Shortcut executes | ✓ Should work |
| Player NOT focused + shortcut key | Shortcut executes (BUG FIX) | ✓ Should work now |
| In input field + shortcut key | Input receives key, no shortcut | ✓ Should work |
| In search box + shortcut key | Search receives key, no shortcut | ✓ Should work |

---

## If It Still Doesn't Work

If shortcuts still don't work when player is unfocused, try:

1. **Clear Extension Cache**
- Go to `about:debugging` in Firefox
- Find ImprovedTube
- Click "Reload"

2. **Hard Reload YouTube**
- Go to YouTube
- Press `Ctrl+Shift+R` (hard refresh)

3. **Check Browser Console for Errors**
- Press `F12` to open Developer Tools
- Go to "Console" tab
- Look for any red error messages
- Report any errors in the GitHub issue

---

## Advanced Debugging (Optional)

If you want to see if the fix is working, open Browser Console and run:

```javascript
// Check if keyboard listeners are attached
console.log("ImprovedTube listeners:", ImprovedTube.input.listeners);

// Check what shortcuts are active
console.log("Active shortcuts:", Object.keys(ImprovedTube.input.listening));
```

You should see something like:
```
ImprovedTube listeners: {keydown: true, keyup: true, wheel: true, improvedtube-blur: true}
Active shortcuts: ['shortcutIncreaseVolume', 'shortcutDecreaseVolume']
```

---

## Summary

This fix improves Firefox compatibility by:
- ✅ Using event.target instead of document.activeElement for key checking
- ✅ Adding document-level listeners for keyboard events
- ✅ Better handling of YouTube's shadow DOM and complex structure
- ✅ Preventing accidental focus-based shortcut blocking

**Browser Support:** Chrome ✓ | Firefox ✓ (after fix) | Firefox Variants (Floorp, Librewolf, etc.) ✓
24 changes: 15 additions & 9 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"hideSuggestedAction": { "message": "Hide Suggested Action 'View products'" },
"hideMerchShelf": { "message": "Hide 'Merch Shelf'" },
{
"hideSuggestedAction": {
"message": "Hide Suggested Action 'View products'"
},
"hideMerchShelf": {
"message": "Hide 'Merch Shelf'"
},
"about": {
"message": "About"
},
Expand Down Expand Up @@ -1615,8 +1619,8 @@
"youtubesLight": {
"message": "YouTube's Light"
},
"smartSpeedEngine":{
"message": "Smart Speed Engine"
"smartSpeedEngine": {
"message": "Smart Speed Engine"
},
"smartSpeedEnable": {
"message": "Enable Smart Speed"
Expand All @@ -1630,12 +1634,14 @@
"smartSpeedMax": {
"message": "Max Speed (Troughs)"
},
"smartSpeedSensitivity":{
"smartSpeedSensitivity": {
"message": "Sensitivity"
},
"smartSpeedTargetToggle": {
"message": "Enable Target Duration" },
"smartSpeedTargetMinutes": { "message": "Target Length (Minutes)"
"message": "Enable Target Duration"
},
"smartSpeedTargetMinutes": {
"message": "Target Length (Minutes)"
},
"smartSpeedProfiles": {
"message": "Category & Channel Profiles"
Expand All @@ -1646,4 +1652,4 @@
"smartSpeedWhitelisted": {
"message": "Channel Whitelisted for Smart Speed!"
}
}
}
10 changes: 5 additions & 5 deletions js&css/web-accessible/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ ImprovedTube.categoryRefreshButton = function () {
svg.appendChild(path3);
button.appendChild(svg);

button.addEventListener('mouseenter', function() {
button.addEventListener('mouseenter', function () {
this.style.background = 'var(--yt-spec-badge-chip-background)';
this.style.borderRadius = '50%';
});
button.addEventListener('mouseleave', function() {
button.addEventListener('mouseleave', function () {
this.style.background = 'transparent';
});

button.addEventListener('click', function() {
button.addEventListener('click', function () {
let chipContainer = document.querySelector('ytd-feed-filter-chip-bar-renderer');

if (chipContainer) {
Expand All @@ -143,7 +143,7 @@ ImprovedTube.categoryRefreshButton = function () {
const allChips = chipContainer.querySelectorAll('yt-chip-cloud-chip-renderer button');
if (allChips.length > 1) {
allChips[1].click();
setTimeout(function() {
setTimeout(function () {
allChips[0].click();
}, 200);
}
Expand All @@ -160,7 +160,7 @@ ImprovedTube.categoryRefreshButton = function () {

addRefreshButton();

const mastheadObserver = new MutationObserver(function() {
const mastheadObserver = new MutationObserver(function () {
if (!document.querySelector('.it-category-refresh-btn')) {
const mastheadButtons = document.querySelector('ytd-masthead #end #buttons');
if (mastheadButtons && mastheadButtons.children.length > 0) {
Expand Down
Loading
Loading