Skip to content
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
7 changes: 4 additions & 3 deletions src/userscript/otherSite/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ export const otherSite = async () => {
}, time);

/** 按照元素的显示高度来排序元素 */
const sortElementsByTop = <T extends HTMLElement>(elements: T[]): T[] => {
const sortElementsByTop = <T extends HTMLElement>(elements: Iterable<T>,): T[] => {
const list = [...elements];
const topMap = new WeakMap<T, number>();
for (const e of elements) topMap.set(e, e.getBoundingClientRect().top);
return elements.toSorted((a, b) => topMap.get(a)! - topMap.get(b)!);
for (const e of list) topMap.set(e, e.getBoundingClientRect().top);
return list.toSorted((a, b) => topMap.get(a)! - topMap.get(b)!);
};

const imageWatcher = new ImageWatcher({
Expand Down