Skip to content

Commit

Permalink
LinkHints: copy-text: always try sending a vimiumData event
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Feb 12, 2024
1 parent 00f26f0 commit 7127339
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions content/link_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const accessElAttr = (isUrlOrText: 0 | 1 | 2): [string: string, isUserCustomized
const format = dataset && hintOptions.access
let el: SafeElement | null | undefined
const cb = (_: string, i: string): string => i.split("||").reduce((v, j) => v || extractField(el!, j), "")
if (dataset && isUrlOrText && (dataset.vimText === "" || dataset.vimUrl === "")) {
dispatchEvent_(clickEl, newEvent_("vimiumData"))
}
for (let accessor of format ? Array.isArray(format) ? format : (format + "").split(",") : []) {
accessor = accessor.trim()
const __arr = accessor.split(":"), selector = __arr.length > 1 ? __arr[0] : 0
Expand All @@ -61,9 +64,6 @@ const accessElAttr = (isUrlOrText: 0 | 1 | 2): [string: string, isUserCustomized
json = json !== props ? json : extractField(el!, props)
if (json) { return [json, 1] }
}
if (dataset && isUrlOrText && (dataset.vimText === "" || dataset.vimUrl === "")) {
dispatchEvent_(clickEl, newEvent_("vimiumData"))
}
return [dataset && ((isUrlOrText > 1 ? dataset.vimText : isUrlOrText && dataset.vimUrl)
|| isUrlOrText < 2 && (dataset.canonicalSrc || dataset.src || tag === "a" && dataset.href)) || ""]
}
Expand Down
5 changes: 4 additions & 1 deletion pages/options_wnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ let optionsInit1_ = function (): void {

delayBinding_("[data-href]", "mousedown", (): void => {
document.onmouseover = null as never
document.removeEventListener("vimiumData", FillDataHref)
for (const element of $$<HTMLAnchorElement & { dataset: KnownOptionsDataset }>("[data-href]")) {
element.onmousedown = null as never
void post_(kPgReq.convertToUrl, [element.dataset.href, Urls.WorkType.ConvertKnown]).then(([str]): void => {
Expand All @@ -183,10 +184,12 @@ let optionsInit1_ = function (): void {
})
}
}, "on")
document.onmouseover = (): void => {
const FillDataHref = (): void => {
didBindEvent_("mousedown")
; ($<HTMLElement>("[data-href]").onmousedown as () => void)()
}
document.onmouseover = FillDataHref
document.addEventListener("vimiumData", FillDataHref)

const openExt = $<HTMLAnchorElement>("#openExtensionsPage");
if (OnChrome && Build.MinCVer < BrowserVer.MinEnsuredChromeURL$ExtensionShortcuts
Expand Down

0 comments on commit 7127339

Please sign in to comment.