diff --git a/src/userscript/otherSite/index.tsx b/src/userscript/otherSite/index.tsx index 5ef44a0f..0bca4c83 100644 --- a/src/userscript/otherSite/index.tsx +++ b/src/userscript/otherSite/index.tsx @@ -164,10 +164,11 @@ export const otherSite = async () => { }, time); /** 按照元素的显示高度来排序元素 */ - const sortElementsByTop = (elements: T[]): T[] => { + const sortElementsByTop = (elements: Iterable,): T[] => { + const list = [...elements]; const topMap = new WeakMap(); - 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({