-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbitbucket_fix_basic_browser_navigation_keybinds.user.js
More file actions
51 lines (48 loc) · 1.94 KB
/
Copy pathbitbucket_fix_basic_browser_navigation_keybinds.user.js
File metadata and controls
51 lines (48 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// ==UserScript==
// @name BitBucket Fix Basic Browser Navigation Keybinds
// @namespace https://github.com/StaticPH
// @match https://bitbucket.org/projects/*/repos/*
// @match https://bitbucket.*.*/projects/*/repos/*
// @version 1.0.0
// @createdAt 1/23/2024, 12:12:24 PM
// @author StaticPH
// @description I am sick and tired of BitBucket breaking basic browser keybinds like history navigation! There are some keyboard shortcuts which should not even be possible for a webpage to interfere with under any circumstances.
// @license MIT
// @updateURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/bitbucket_fix_basic_browser_navigation_keybinds.user.js
// @downloadURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/bitbucket_fix_basic_browser_navigation_keybinds.user.js
// @homepageURL https://github.com/StaticPH/UserScripts
// @supportURL https://github.com/StaticPH/UserScripts/issues
// @icon https://bitbucket.org/favicon.ico
// @grant none
// @run-at document-end
// @noframes
// ==/UserScript==
(function(){
"use strict";
// And this STILL doesn't fix the page content not always being correct after navigation, because AJAX is stupid like that.
// let readyForNextNav = true;
function fixedGlobalKeyBinds(evnt){
// if (!readyForNextNav){return;}
if (evnt.altKey && !evnt.repeat && !evnt.shiftKey && !evnt.ctrlKey){
// readyForNextNav = false;
switch (evnt.key){
case "Left":
case "ArrowLeft":
evnt.stopImmediatePropagation();
evnt.stopPropagation();
evnt.preventDefault();
window.history.back();
break;
case "Right":
case "ArrowRight":
evnt.stopImmediatePropagation();
evnt.stopPropagation();
evnt.preventDefault();
window.history.forward();
break;
}
// readyForNextNav = true;
}
}
document.addEventListener('keydown', fixedGlobalKeyBinds);
})();