Skip to content

Commit

Permalink
LinkHints: avoid useless hints on Baidu search result pages
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Jun 22, 2019
1 parent 8296f03 commit 9c122bb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions content/link_hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ var VHints = {
let el = (anchor.rel || anchor.hasAttribute("ping"))
&& anchor.firstElementChild as Element | null;
return el && this._HNTagRe.test(VDom.htmlTag_(el))
&& this.isNotReplacedBy_(el as SafeHTMLElement) ? VDom.getVisibleClientRect_(el) : null;
&& this.isNotReplacedBy_(el as HTMLHeadingElement & SafeHTMLElement) ? VDom.getVisibleClientRect_(el) : null;
},
isNotReplacedBy_ (element: SafeHTMLElement | null, isExpected?: Hint[]): boolean | null {
const arr2: Hint[] = [], a = this, clickListened = a.isClickListened_;
Expand All @@ -433,13 +433,15 @@ var VHints = {
inferTypeOfListener_ (el: SafeHTMLElement, tag: string): boolean {
// Note: should avoid nested calling to isNotReplacedBy_
let el2: Element | null | undefined;
return tag !== "div"
return tag !== "div" && tag !== "li"
? tag === "tr" ? !!this.isNotReplacedBy_(el.querySelector("input[type=checkbox]") as SafeHTMLElement | null)
: tag !== "table"
: !(el2 = el.firstElementChild as Element | null) ||
!(!el.className && !el.id
|| VDom.clickable_.has(el2) && ((tag = VDom.htmlTag_(el2)) === "div" || tag === "span")
!(!el.className && !el.id && tag === "div"
|| ((tag = VDom.htmlTag_(el2)) === "div" || tag === "span") && VDom.clickable_.has(el2)
&& el2.getClientRects().length
|| VHints._HNTagRe.test(tag) && (el2 = (el2 as HTMLHeadingElement).firstElementChild as Element | null)
&& VDom.htmlTag_(el2) === "a"
);
},
/** Note: required by {@link #kFgCmd.focusInput}, should only add SafeHTMLElement instances */
Expand Down

0 comments on commit 9c122bb

Please sign in to comment.