Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves detection of end of library #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ func (s *Session) setFirstItem(ctx context.Context) error {
func navToEnd(ctx context.Context) error {
// try jumping to the end of the page. detect we are there and have stopped
// moving when two consecutive screenshots are identical.
// a minimum floor of duplicate screenshots is used to overcome any
// any false positives in determining the end of some larger libraries
var previousScr, scr []byte
minAmountOfDuplicateScr := 3
amountOfDuplicateScr := 0
for {
chromedp.KeyEvent(kb.PageDown).Do(ctx)
chromedp.KeyEvent(kb.End).Do(ctx)
Expand All @@ -325,7 +329,15 @@ func navToEnd(ctx context.Context) error {
continue
}
if bytes.Equal(previousScr, scr) {
break
amountOfDuplicateScr++
if *verboseFlag {
log.Printf("Screen is equal to previous screen, waiting to hit threshold [%v/%v]", amountOfDuplicateScr, minAmountOfDuplicateScr)
}
if amountOfDuplicateScr == minAmountOfDuplicateScr {
break
}
} else {
amountOfDuplicateScr = 0
}
previousScr = scr
time.Sleep(tick)
Expand Down