mirror of
https://github.com/snachodog/tok-to-insta-follower-bridge.git
synced 2025-04-10 14:11:22 -06:00
✨ skip out of top viewport
This commit is contained in:
parent
1043d1e45e
commit
5f11e76484
@ -1,3 +1,4 @@
|
||||
import { isOutOfTopViewport } from './lib/domHelpers';
|
||||
import { BskyClient } from "./lib/bskyClient";
|
||||
import type { PlasmoCSConfig } from "plasmo"
|
||||
import { MESSAGE_NAMES } from "~lib/constants";
|
||||
@ -37,7 +38,11 @@ const searchBskyUsers = async ({
|
||||
const userCells = getUserCells()
|
||||
debugLog(`userCells length: ${userCells.length}`)
|
||||
|
||||
for (const [index, userCell] of userCells.entries()) {
|
||||
let index = 0
|
||||
for (const userCell of userCells) {
|
||||
if(isOutOfTopViewport(userCell)) {
|
||||
continue
|
||||
}
|
||||
const { twAccountName, twDisplayName } = getAccountNameAndDisplayName(userCell)
|
||||
if (notFoundUserCache.has(twAccountName)) {
|
||||
insertNotFoundEl(userCell)
|
||||
@ -96,6 +101,8 @@ const searchBskyUsers = async ({
|
||||
notFoundUserCache.add(twAccountName)
|
||||
}
|
||||
}
|
||||
|
||||
index++
|
||||
if (process.env.NODE_ENV === "development" && index > 5) {
|
||||
break
|
||||
}
|
||||
|
@ -144,3 +144,8 @@ export const cleanBskyUserElements = () => {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const isOutOfTopViewport = (el: Element) => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return rect.top < 0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user