v0.2.0 759cc92

injected-controls.ts RawHistoryFolder

1/**
2 * Injectable Controls Script
3 * 
4 * This script is injected into every page loaded in the browser to provide
5 * global keyboard and mouse controls that work on all domains.
6 * 
7 * Only includes essential controls that can work cross-origin:
8 * - Navigation (back/forward)
9 * - URL copying
10 * - Mouse navigation buttons
11 * 
12 * Zoom controls are handled natively by the GTK backend
13 */
14
15(function() {
16  'use strict';
17  
18  // Prevent multiple injections with a unique timestamp
19  const injectionId = '__dumberControlsInjected_' + Date.now();
20  if ((window as any).__dumberControlsInjected) {
21    console.log('🔄 Dumber Browser controls already injected, skipping');
22    return;
23  }
24  (window as any).__dumberControlsInjected = injectionId;
25  
26  console.log('🚀 Dumber Browser controls injected on:', window.location.href);
27  
28  // Keyboard event handler for global controls
29  function handleKeyboardEvent(event: KeyboardEvent): void {
30    const { ctrlKey, metaKey, shiftKey, altKey, key } = event;
31    const isCmd = ctrlKey || metaKey;
32    
33    try {
34      // Copy URL (Cmd+Shift+C)
35      if (isCmd && shiftKey && key === 'C') {
36        event.preventDefault();
37        event.stopPropagation();
38        
39        // Copy current URL to clipboard
40        if (navigator.clipboard && navigator.clipboard.writeText) {
41          navigator.clipboard.writeText(window.location.href)
42            .then(() => console.log('🔗 URL copied:', window.location.href))
43            .catch((err) => console.error('❌ Failed to copy URL:', err));
44        } else {
45          console.warn('⚠️ Clipboard API not available');
46        }
47        return;
48      }
49      
50      // Navigation: Alt + Left Arrow (Back)
51      if (altKey && key === 'ArrowLeft') {
52        event.preventDefault();
53        event.stopPropagation();
54        
55        if (window.history.length > 1) {
56          console.log('⬅️ Navigating back');
57          window.history.back();
58        }
59        return;
60      }
61      
62      // Navigation: Alt + Right Arrow (Forward)
63      if (altKey && key === 'ArrowRight') {
64        event.preventDefault();
65        event.stopPropagation();
66        
67        console.log('➡️ Navigating forward');
68        window.history.forward();
69        return;
70      }
71      
72    } catch (error) {
73      console.error('❌ Error in keyboard handler:', error);
74    }
75  }
76  
77  // Mouse event handler for navigation buttons
78  function handleMouseEvent(event: MouseEvent): void {
79    try {
80      // Mouse button 3 (back button)
81      if (event.button === 3) {
82        event.preventDefault();
83        event.stopPropagation();
84        
85        if (window.history.length > 1) {
86          console.log('⬅️ Mouse back button pressed');
87          window.history.back();
88        }
89        return;
90      }
91      
92      // Mouse button 4 (forward button)
93      if (event.button === 4) {
94        event.preventDefault();
95        event.stopPropagation();
96        
97        console.log('➡️ Mouse forward button pressed');
98        window.history.forward();
99        return;
100      }
101      
102    } catch (error) {
103      console.error('❌ Error in mouse handler:', error);
104    }
105  }
106  
107  // Add event listeners with high priority (capture phase)
108  try {
109    document.addEventListener('keydown', handleKeyboardEvent, true);
110    document.addEventListener('mousedown', handleMouseEvent, true);
111    
112    console.log('✅ Dumber Browser global controls active');
113    
114    // Cleanup function for when page is unloaded
115    window.addEventListener('beforeunload', () => {
116      document.removeEventListener('keydown', handleKeyboardEvent, true);
117      document.removeEventListener('mousedown', handleMouseEvent, true);
118      console.log('🧹 Dumber Browser controls cleaned up');
119    });
120    
121  } catch (error) {
122    console.error('❌ Failed to initialize Dumber Browser controls:', error);
123  }
124})();

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close