From 2c6a37c2480caabaa4877c48573d63e242ba27b7 Mon Sep 17 00:00:00 2001 From: piquark6046 Date: Fri, 27 Dec 2024 06:16:38 +0000 Subject: [PATCH] fix: score-based detection --- package.json | 2 +- sources/banner.txt | 2 +- sources/src/index.ts | 32 +++++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c442479..12997f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@list-kr/namulink", - "version": "5.1.7", + "version": "5.1.8", "description": "", "type": "module", "scripts": { diff --git a/sources/banner.txt b/sources/banner.txt index 2a9daca..43dd8e7 100644 --- a/sources/banner.txt +++ b/sources/banner.txt @@ -8,7 +8,7 @@ // @downloadURL https://cdn.jsdelivr.net/npm/@list-kr/namulink@latest/dist/NamuLink.user.js // @license MIT // -// @version 5.1.7 +// @version 5.1.8 // @author PiQuark6046 and contributors // // @match https://namu.wiki/* diff --git a/sources/src/index.ts b/sources/src/index.ts index a87884f..3b2d68e 100644 --- a/sources/src/index.ts +++ b/sources/src/index.ts @@ -7,7 +7,9 @@ const Win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window let HideLeftover = () => { setInterval(() => { Array.from(document.querySelectorAll('div[class*=" "] div[class]')).filter((TargetEle: HTMLElement) => { - return (TargetEle.innerText === '' || TargetEle.innerText.includes('파워링크')) && + return (Array.from(TargetEle.querySelectorAll('*')).filter((ChildEle: HTMLElement) => { + return getComputedStyle(ChildEle).getPropertyValue('animation').includes('infinite') + }).length >= 6 || TargetEle.innerText === '' || TargetEle.innerText.includes('파워링크')) && (Number(getComputedStyle(TargetEle).getPropertyValue('margin-top').replace('px', '')) > 10 || Number(getComputedStyle(TargetEle).getPropertyValue('margin-bottom').replace('px', '')) > 10) && Number(getComputedStyle(TargetEle).getPropertyValue('height').replace('px', '')) < 350 }).forEach((TargetEle: HTMLElement) => { @@ -39,6 +41,34 @@ Win.Proxy = new Proxy(Win.Proxy, { }) return Reflect.construct(Target, [Args[0], ArgsObj], NewTarget) } + if (typeof Args[0] === 'object' && Object.keys(Args[0]).some((Key: string) => typeof Args[0][Key] === 'string' && Args[0][Key].includes('searchad.naver.com'))) { + HideLeftover() + return + } + + // Object inner section analysis + let TensorResult: Array = [0, 0, 0] // string, number, boolean + if (typeof Args[0] === 'object') { + Object.keys(Args[0]).forEach((Key: string) => { + switch (typeof Args[0][Key]) { + case 'string': + TensorResult[0]++ + break + case 'number': + TensorResult[1]++ + break + case 'boolean': + TensorResult[2]++ + break + } + }) + } + if (TensorResult.every((Result) => Result >= 3)) { + HideLeftover() + return + } + // + return Reflect.construct(Target, Args, NewTarget) } }) \ No newline at end of file