Skip to content

Commit

Permalink
fix: some wiki content elements are placed in a wrong loc
Browse files Browse the repository at this point in the history
  • Loading branch information
piquark6046 committed Oct 29, 2024
1 parent 4d02d8c commit 3f60fe2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 40 deletions.
27 changes: 27 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import tsPlugin from "@typescript-eslint/eslint-plugin"
import tsParser from "@typescript-eslint/parser"

const config = [
{
files: ["**/*.ts", "**/*.tsx"], // Target TypeScript files
languageOptions: {
parser: tsParser,
sourceType: "module",
},
plugins: {
"@typescript-eslint": tsPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,
"semi": ["error", "never"],
"quotes": ["error", "single"],
"@typescript-eslint/no-unused-vars": "warn",
'@typescript-eslint/naming-convention': ['error', {
selector: ['variableLike', 'parameterProperty', 'classProperty', 'typeProperty'],
format: ['PascalCase']
}]
}
}
]

export default config
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@list-kr/namulink",
"version": "4.0.14",
"version": "4.1.0",
"description": "",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -38,18 +38,16 @@
],
"license": "MIT",
"dependencies": {
"@types/node": "^20.14.10",
"@types/node": "^20.17.1",
"is-valid-domain": "^0.1.6",
"multithread-array": "^2.0.0",
"p-limit": "^6.1.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"esbuild": "^0.21.5",
"eslint": "^8.57.0",
"pnpm": "^9.5.0",
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.0"
"esbuild": "^0.24.0",
"eslint": "^9.13.0",
"pnpm": "^9.12.3",
"typescript": "^5.6.3",
"typescript-eslint": "^8.11.0"
}
}
25 changes: 0 additions & 25 deletions sources/.eslintrc.cjs

This file was deleted.

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 4.0.14
// @version 4.1.0
// @author PiQuark6046 and contributors
//
// @match https://namu.wiki/*
Expand Down
7 changes: 2 additions & 5 deletions sources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import PLimit from 'p-limit'
import {SplitElementsIntoSubArrayLength} from 'multithread-array'

type unsafeWindow = typeof window
// eslint-disable-next-line @typescript-eslint/no-redeclare, @typescript-eslint/naming-convention
// eslint-disable-next-line @typescript-eslint/naming-convention
declare const unsafeWindow: unsafeWindow

// eslint-disable-next-line no-negated-condition
const Win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window

const RemoveElements = (TargetElements: HTMLElement[]) => {
TargetElements.forEach(TargetElement => {
TargetElement.remove()
TargetElement.setAttribute('style', 'visibility: hidden !important; width: 1px !important; height: 1px !important;')
})
}

Expand All @@ -29,7 +28,6 @@ const RemovePowerLinkAdWorker = (SearchedElements: HTMLElement[]): HTMLElement[]
TargetedElements = TargetedElements.filter(SearchedElement => {
return Array.from(SearchedElement.querySelectorAll('a,span,div')).filter(HTMLInElement => {
return HTMLInElement instanceof HTMLElement
// eslint-disable-next-line no-irregular-whitespace
&& IsValidDomain((HTMLInElement.innerText.replaceAll(/ /g, '').match(/^[^/]+(?=\/)?/g) ?? [''])[0], { allowUnicode: true, subdomain: true }) // Zero width space and space should be removed.
}).length >= 2
|| Array.from(SearchedElement.querySelectorAll('*')).filter(HTMLInElement => {
Expand All @@ -44,7 +42,6 @@ const RemovePowerLinkAdWorker = (SearchedElements: HTMLElement[]): HTMLElement[]
})
TargetedElements = TargetedElements.filter(SearchedElement => {
return Array.from(SearchedElement.querySelectorAll('*[href^="#fn-"]')).filter(HTMLInElement => {
// eslint-disable-next-line no-irregular-whitespace
return HTMLInElement instanceof HTMLElement && /\[[0-9]+\]/.test(HTMLInElement.innerText.replaceAll(/ /g, '')) // Zero width space and space should be removed.
}).length === 0
})
Expand Down

0 comments on commit 3f60fe2

Please sign in to comment.