Skip to content

Commit

Permalink
iter over images on twitter
Browse files Browse the repository at this point in the history
* update `nextPatterns`
* and exclude those with `[aria-haspopup]`

for #559
  • Loading branch information
gdh1995 committed Mar 6, 2022
1 parent fb02874 commit d6c6e6a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions background/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions content/local_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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
, (<ScrollByY> (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))
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions content/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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))
}

Expand All @@ -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")) ? (<RegExpI> /^(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])
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/dom_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 => {
Expand Down
4 changes: 2 additions & 2 deletions settings-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion typings/messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d6c6e6a

Please sign in to comment.