brandon1024 / find

A find-in-page extension for Chrome and Firefox that supports regular expressions.
https://chrome.google.com/webstore/detail/find%2B-regex-find-in-page/fddffkdncgkkdjobemgbpojjeffmmofb
GNU General Public License v3.0
402 stars 52 forks source link

wrong count #393

Open davidp88 opened 1 year ago

davidp88 commented 1 year ago

Open this site- https://www.gpsoft.com.au/program/program.html and search for "opus",there are only 14 matches for opus but find shows 16 matches found.Even firefox says 14 matches only.

Aybee commented 1 year ago

It also finds occurrences that are hidden by CSS. Sometimes this can also be an advantage.

davidp88 commented 1 year ago

Showing matches that are hidden by Css is not correct,pls exclude matches that are hidden by css

Aybee commented 1 year ago

Who said so?

brandon1024 commented 1 year ago

The two extra occurrences are from the navbar, which have a visibility: hidden style applied to them. In the extensions plugin scripts, isHiddenElement doesn't account for this. Should be an easy fix.

Aybee commented 1 year ago

There are many other ways to hide elements from visibility. E.g. this often used class to show elements only to screenreaders from Contao CMS

.invisible {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

or this from Bootstrap

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

But there are many others

Element {
    overflow: hidden;
    text-indent: 100%;
}
Element {
    position: absolute;
    z-index: -1;
}
Element {
    position: absolute;
    left: -10000px;
}
Element {
    height: 0;
    overflow: hidden;
}

And more ...

You can find many approaches on the web to find out whether the visitor sees an element or rather a text or not. I think they can all fail somehow. So this ticket is definitely not a bug.

You have to turn CSS off, to see everything.

mrienstra commented 1 year ago

Chrome's built-in search also matches text in some types of hidden nodes, e.g. on this page (desktop), a search for quote will find an "invisible" occurrence, inside the tooltip for the quote button. The tooltip uses the same .sr-only CSS @Aybee shared above.

Screen Shot 2023-03-03 at 10 22 54 AM