mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Make focus prevent loop more CPU friendly; uncouple from allowautofocus
This commit is contained in:
parent
fff155e142
commit
db7eb12ca6
2 changed files with 7 additions and 2 deletions
|
@ -73,7 +73,7 @@ document.addEventListener("readystatechange", _ =>
|
|||
)
|
||||
|
||||
// Prevent pages from automatically focusing elements on load
|
||||
config.getAsync("allowautofocus").then(allowautofocus => {
|
||||
config.getAsync("preventautofocusjackhammer").then(allowautofocus => {
|
||||
if (allowautofocus === "true") {
|
||||
return
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ config.getAsync("allowautofocus").then(allowautofocus => {
|
|||
// On top of blur/focusout events, we need to periodically check the
|
||||
// activeElement is the one we want because blur/focusout events aren't
|
||||
// always triggered when document.activeElement changes
|
||||
const interval = setInterval(() => { if (document.activeElement != elem) focusElem() }, 10)
|
||||
const interval = setInterval(() => { if (document.activeElement != elem) focusElem() }, 200)
|
||||
// When the user starts interacting with the page, stop resetting focus
|
||||
function stopResettingFocus() {
|
||||
elem.removeEventListener("blur", focusElem)
|
||||
|
|
|
@ -589,6 +589,11 @@ class default_config {
|
|||
*/
|
||||
allowautofocus: "true" | "false" = "true"
|
||||
|
||||
/**
|
||||
* Uses a loop to prevent focus until you interact with a page. Only recommended for use via `seturl` for problematic sites as it can be a little heavy on CPU if running on all tabs. Should be used in conjuction with [[allowautofocus]]
|
||||
*/
|
||||
preventautofocusjackhammer: "true" | "false" = "true"
|
||||
|
||||
/**
|
||||
* Controls whether the newtab focuses on tridactyl's newtab page or the firefox urlbar.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue