Skip to content

Commit

Permalink
fix: score-based detection
Browse files Browse the repository at this point in the history
  • Loading branch information
piquark6046 committed Dec 27, 2024
1 parent af967f1 commit 2c6a37c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@list-kr/namulink",
"version": "5.1.7",
"version": "5.1.8",
"description": "",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion sources/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
32 changes: 31 additions & 1 deletion sources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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<number> = [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)
}
})

0 comments on commit 2c6a37c

Please sign in to comment.