mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Fix dom.getLastUsedInput() not working on webextension pages
This commit is contained in:
parent
a6374ee9f5
commit
a2e0486e95
2 changed files with 12 additions and 11 deletions
|
@ -119,16 +119,11 @@ import * as updates from "@src/lib/updates"
|
||||||
|
|
||||||
logger.info("Loaded commandline content?", commandline_content)
|
logger.info("Loaded commandline content?", commandline_content)
|
||||||
|
|
||||||
// Don't hijack on the newtab page.
|
try {
|
||||||
if (webext.inContentScript()) {
|
dom.setupFocusHandler()
|
||||||
try {
|
dom.hijackPageListenerFunctions()
|
||||||
dom.setupFocusHandler()
|
} catch (e) {
|
||||||
dom.hijackPageListenerFunctions()
|
logger.warning("Could not hijack due to CSP:", e)
|
||||||
} catch (e) {
|
|
||||||
logger.warning("Could not hijack due to CSP:", e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.warning("No export func")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
activeTabId,
|
activeTabId,
|
||||||
openInNewTab,
|
openInNewTab,
|
||||||
activeTabContainerId,
|
activeTabContainerId,
|
||||||
|
inContentScript
|
||||||
} from "@src/lib/webext"
|
} from "@src/lib/webext"
|
||||||
const logger = new Logging.Logger("dom")
|
const logger = new Logging.Logger("dom")
|
||||||
|
|
||||||
|
@ -446,6 +447,9 @@ export function registerEvListenerAction(
|
||||||
* same with removeEventListener.
|
* same with removeEventListener.
|
||||||
*/
|
*/
|
||||||
export function hijackPageListenerFunctions(): void {
|
export function hijackPageListenerFunctions(): void {
|
||||||
|
if (!inContentScript()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const exportedName = "registerEvListenerAction"
|
const exportedName = "registerEvListenerAction"
|
||||||
exportFunction(registerEvListenerAction, window, { defineAs: exportedName })
|
exportFunction(registerEvListenerAction, window, { defineAs: exportedName })
|
||||||
|
|
||||||
|
@ -543,7 +547,9 @@ export function setupFocusHandler(): void {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Handles when the page tries to select an input
|
// Handles when the page tries to select an input
|
||||||
hijackPageFocusFunction()
|
if (inContentScript()) {
|
||||||
|
hijackPageFocusFunction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CSS selectors. More readable for web developers. Not dead. Leaves browser to care about XML.
|
// CSS selectors. More readable for web developers. Not dead. Leaves browser to care about XML.
|
||||||
|
|
Loading…
Add table
Reference in a new issue