From 3f60fe28f8eed9382ad24846fd250f9c6da9a228 Mon Sep 17 00:00:00 2001 From: piquark6046 Date: Tue, 29 Oct 2024 06:18:49 +0000 Subject: [PATCH] fix: some wiki content elements are placed in a wrong loc https://gall.dcinside.com/mgallery/board/view/?id=adguard&no=67&page=1 --- eslint.config.js | 27 +++++++++++++++++++++++++++ package.json | 16 +++++++--------- sources/.eslintrc.cjs | 25 ------------------------- sources/banner.txt | 2 +- sources/src/index.ts | 7 ++----- 5 files changed, 37 insertions(+), 40 deletions(-) create mode 100644 eslint.config.js delete mode 100644 sources/.eslintrc.cjs diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..31728f2 --- /dev/null +++ b/eslint.config.js @@ -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 \ No newline at end of file diff --git a/package.json b/package.json index fc16bcd..abb455c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@list-kr/namulink", - "version": "4.0.14", + "version": "4.1.0", "description": "", "type": "module", "scripts": { @@ -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" } } diff --git a/sources/.eslintrc.cjs b/sources/.eslintrc.cjs deleted file mode 100644 index e471f37..0000000 --- a/sources/.eslintrc.cjs +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - ], - parser: '@typescript-eslint/parser', - parserOptions: { - tsconfigRootDir: __dirname, - project: '../tsconfig.json' - }, - plugins: ['@typescript-eslint'], - rules: { - '@typescript-eslint/naming-convention': ['error', { - selector: ['variableLike', 'parameterProperty', 'classProperty', 'typeProperty'], - format: ['PascalCase'] - }], - '@typescript-eslint/prefer-nullish-coalescing': 'off', - 'new-cap': 'off', - 'no-var': 'off', - 'comma-dangle': 'off', - indent: ['off', 'tab'], - semi: ['error', 'never'] - }, - ignorePatterns: ['dist', 'node_modules', '.eslintrc.cjs'] -} \ No newline at end of file diff --git a/sources/banner.txt b/sources/banner.txt index d490658..73f6cc2 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 4.0.14 +// @version 4.1.0 // @author PiQuark6046 and contributors // // @match https://namu.wiki/* diff --git a/sources/src/index.ts b/sources/src/index.ts index ce24782..7c38d10 100644 --- a/sources/src/index.ts +++ b/sources/src/index.ts @@ -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;') }) } @@ -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 => { @@ -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 })