diff --git a/background/settings.ts b/background/settings.ts index 79e97eb42..fe901cac2 100644 --- a/background/settings.ts +++ b/background/settings.ts @@ -301,11 +301,11 @@ saladict@crimx.com` mouseReachable: true, /** mutable */ newTabUrl: "", nextPatterns: "\u4e0b\u4e00\u5c01,\u4e0b\u9875,\u4e0b\u4e00\u9875,\u4e0b\u4e00\u7ae0,\u540e\u4e00\u9875\ -,next,more,newer,>,\u203a,\u2192,\xbb,\u226b,>>", +,\u4e0b\u4e00\u5f20,next,more,newer,>,\u203a,\u2192,\xbb,\u226b,>>", omniBlockList: "", passEsc: "[aria-controls],[role=combobox],#kw.s_ipt", // MS Bing / Google / Baidu previousPatterns: "\u4e0a\u4e00\u5c01,\u4e0a\u9875,\u4e0a\u4e00\u9875,\u4e0a\u4e00\u7ae0,\u524d\u4e00\u9875\ -,prev,previous,back,older,<,\u2039,\u2190,\xab,\u226a,<<", +,\u4e0a\u4e00\u5f20,prev,previous,back,older,<,\u2039,\u2190,\xab,\u226a,<<", regexFindMode: false, scrollStepSize: 100, searchUrl: (navigator.language as string).startsWith("zh") ? "https://www.baidu.com/s?ie=utf-8&wd=%s \u767e\u5ea6" diff --git a/content/local_links.ts b/content/local_links.ts index 3b9b99948..f509e8454 100644 --- a/content/local_links.ts +++ b/content/local_links.ts @@ -3,7 +3,7 @@ import { math, includes_, OnFirefox, OnEdge, WithDialog, safeCall, evenHidden_, set_evenHidden_, tryCreateRegExp, loc_ } from "../lib/utils" import { - isIFrameElement, getInputType, uneditableInputs_, getComputedStyle_, findMainSummary_, htmlTag_, isAriaNotTrue_, + isIFrameElement, getInputType, uneditableInputs_, getComputedStyle_, findMainSummary_, htmlTag_, isAriaFalse_, kMediaTag, NONE, querySelector_unsafe_, isStyleVisible_, fullscreenEl_unsafe_, notSafe_not_ff_, docEl_unsafe_, GetParent_unsafe_, unsafeFramesetTag_old_cr_, isHTML_, querySelectorAll_unsafe_, isNode_, INP, attr_s, getMediaTag, getMediaUrl, contains_s, GetShadowRoot_, parentNode_unsafe_s, testMatch, hasTag_ @@ -159,12 +159,12 @@ const getClickable = (hints: Hint[], element: SafeHTMLElement): void => { if (isClickable && (arr = tag === "img" ? getZoomedAndCroppedRect_(element as HTMLImageElement, null, true) : arr || getVisibleClientRect_(element, null)) - && (isAriaNotTrue_(element, kAria.hidden) || extraClickable_ && extraClickable_.has(element)) + && (isAriaFalse_(element, kAria.hidden) || extraClickable_ && extraClickable_.has(element)) && (type < ClickType.scrollX || shouldScroll_s(element , ( (type - ClickType.scrollX) + <0 | 2> (evenHidden_ & kHidden.OverflowHidden)) as BOOL | 2 | 3 , 0) > 0) - && (mode1_ > HintMode.min_job - 1 || isAriaNotTrue_(element, kAria.disabled)) + && (mode1_ > HintMode.min_job - 1 || isAriaFalse_(element, kAria.disabled)) && (type < ClickType.codeListener || type > ClickType.classname || !(s = element.getAttribute("unselectable")) || s.toLowerCase() !== "on") && (0 === clickTypeFilter_ || clickTypeFilter_ & (1 << type)) @@ -343,8 +343,8 @@ const isOtherClickable = (hints: Hint[], element: NonHTMLButFormattedElement | S : tabIndex != null && tabIndex >= 0 ? element.localName === "a" ? ClickType.attrListener : ClickType.tabindex : ClickType.Default if (type && (arr = getVisibleClientRect_(element, null)) - && isAriaNotTrue_(element, kAria.hidden) - && (mode1_ > HintMode.min_job - 1 || isAriaNotTrue_(element, kAria.disabled)) + && isAriaFalse_(element, kAria.hidden) + && (mode1_ > HintMode.min_job - 1 || isAriaFalse_(element, kAria.disabled)) && (0 === clickTypeFilter_ || clickTypeFilter_ & (1 << type)) ) { hints.push([element, arr, type]) @@ -694,7 +694,7 @@ export const filterOutNonReachable = (list: Hint[], notForAllClickable?: boolean } else { while (temp = stack[index2], index2++ < elPos && (OnFirefox || !notSafe_not_ff_!(temp)) - && (!isAriaNotTrue_(temp as SafeElement, kAria.hidden) + && (!isAriaFalse_(temp as SafeElement, kAria.hidden) || contains_s(temp as SafeElement, el))) { /* empty */ } temp = temp !== fromPoint && contains_s(el, temp) ? el : temp } diff --git a/content/pagination.ts b/content/pagination.ts index ba3becaab..479dbe1c2 100644 --- a/content/pagination.ts +++ b/content/pagination.ts @@ -3,7 +3,7 @@ import { OnChrome, OnFirefox, OnEdge, evenHidden_ } from "../lib/utils" import { - docEl_unsafe_, htmlTag_, isAriaNotTrue_, isStyleVisible_, querySelectorAll_unsafe_, isIFrameElement, ALA, attr_s, + docEl_unsafe_, htmlTag_, isAriaFalse_, isStyleVisible_, querySelectorAll_unsafe_, isIFrameElement, ALA, attr_s, contains_s, notSafe_not_ff_, hasTag_ } from "../lib/dom_utils" import { getBoundingClientRect_, view_ } from "../lib/rect" @@ -20,8 +20,7 @@ let iframesToSearchForNext: VApiTy[] | null export const isInteractiveInPage = (element: SafeElement): boolean => { let rect: ClientRect - return isAriaNotTrue_(element, kAria.disabled) - && (rect = getBoundingClientRect_(element)).width > 2 && rect.height > 2 + return (rect = getBoundingClientRect_(element)).width > 2 && rect.height > 2 && (isStyleVisible_(element) || !!(evenHidden_ & kHidden.VisibilityHidden)) } @@ -43,7 +42,8 @@ export const filterTextToGoNext: VApiTy["g"] = (candidates, names, options, maxL || (OnFirefox ? (element as HTMLElement | SVGElement).onclick : attr_s(element, "onclick")) || ((s = attr_s(element, "role")) ? ( /^(button|link)$/i).test(s) : ngEnabled && attr_s(element, "ng-click"))) { - if (isInteractiveInPage(element)) { + if ((isAriaFalse_(element, kAria.disabled) && isAriaFalse_(element, kAria.hasPopup) || fromMatchSelector) + && isInteractiveInPage(element)) { hints.push([element as SafeElementForMouse]) } } diff --git a/lib/dom_utils.ts b/lib/dom_utils.ts index ff44c62b0..06f1b299f 100644 --- a/lib/dom_utils.ts +++ b/lib/dom_utils.ts @@ -14,6 +14,7 @@ interface kNodeToType { export const DAC = "DOMActivate", MDW = "mousedown", CLK = "click", HDN = "hidden", NONE = "none" export const INP = "input", BU = "blur", ALA = "aria-label", UNL = "unload" export const kDir = ["backward", "forward"] as const +const kAria = ["aria-hidden", "aria-disabled", "aria-haspopup"] as const //#region data and DOM-shortcut section @@ -371,9 +372,9 @@ export const IsInDOM_ = function (element: Element, root?: Element | Document | export const isStyleVisible_ = (element: Element): boolean => isRawStyleVisible(getComputedStyle_(element)) export const isRawStyleVisible = (style: CSSStyleDeclaration): boolean => style.visibility === "visible" -export const isAriaNotTrue_ = (element: SafeElement, ariaType: kAria): boolean => { - let s = element.getAttribute(ariaType ? "aria-disabled" : "aria-hidden"); - return s === null || (!!s && Lower(s) !== "true") || !!(evenHidden_ & (kHidden.BASE_ARIA << ariaType)) +export const isAriaFalse_ = (element: SafeElement, ariaType: kAria): boolean => { + let s = element.getAttribute(kAria[ariaType]) + return s === null || (!!s && Lower(s) === "false") || !!(evenHidden_ & (kHidden.BASE_ARIA << ariaType)) } export const hasInCSSFilter_ = (): boolean => { diff --git a/settings-template.json b/settings-template.json index e5be0e89e..202eacfe2 100644 --- a/settings-template.json +++ b/settings-template.json @@ -178,9 +178,9 @@ ], "linkHintCharacters": "dsavewrqcxz", "nextPatterns": - "下一封,下页,下一页,下一章,后一页,.btn-next,[data-slp-action=nextSlide]:not(div),next,more,newer,>,›,→,»,≫,>>", + "下一封,下页,下一页,下一章,后一页,上一张,.btn-next,[data-slp-action=nextSlide]:not(div),next,more,newer,>,›,→,»,≫,>>", "previousPatterns": - "上一封,上页,上一页,上一章,前一页,.btn-prev,[data-slp-action=prevSlide]:not(div),prev,previous,back,older,<,‹,←,«,≪,<<", +"上一封,上页,上一页,上一章,前一页,下一张,.btn-prev,[data-slp-action=prevSlide]:not(div),prev,previous,back,older,<,‹,←,«,≪,<<", "searchEngines": [ "b|吧|把|ba|bd|baidu|Baidu|百度: https://www.baidu.com/s?ie=utf-8&wd=$s \\", " blank=https://www.baidu.com", diff --git a/typings/messages.d.ts b/typings/messages.d.ts index b394c527a..f91c716fc 100644 --- a/typings/messages.d.ts +++ b/typings/messages.d.ts @@ -41,7 +41,7 @@ interface ParsedSearch { /** error */ e?: string | null; } -declare const enum kAria { hidden = 0, disabled = 1 } +declare const enum kAria { hidden = 0, disabled = 1, hasPopup = 2 } declare const enum kHidden { None = 0, VisibilityHidden = 1, OverflowHidden = 2, BASE_ARIA = 16, AriaHidden = BASE_ARIA << kAria.hidden, AriaDisabled = BASE_ARIA << kAria.disabled,