Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3eb385d
refactor: design monorepos
piquark6046 Jan 14, 2026
1b9724c
ci: fix ESLint chain
piquark6046 Jan 14, 2026
2973ddc
ci: expand ESLint checking to all Typescript files
piquark6046 Jan 14, 2026
f2bf1af
refactor: split IAB sellers downloader
piquark6046 Jan 15, 2026
0173bdb
refactor: update pacakge.json in `builder`
piquark6046 Jan 15, 2026
b7c2fd8
fix: `baseUrl` in `tsconfig.json` leads fatal of `tsx` execution
piquark6046 Jan 15, 2026
45468db
chore: add http-server utils
piquark6046 Jan 16, 2026
e4dcb6a
chore: update .gitignore and package.json for new monorepo structure
piquark6046 Jan 16, 2026
f2532bd
Potential fix for code scanning alert no. 4: Uncontrolled data used i…
piquark6046 Jan 18, 2026
f6f448f
chore: follow PascalCase
piquark6046 Jan 18, 2026
785d139
Potential fix for code scanning alert no. 9: Uncontrolled data used i…
piquark6046 Jan 18, 2026
57f8f26
feat: add `IndexAdShieldDomainsFromAG` func to refer AG Base filters …
piquark6046 Jan 18, 2026
5d8fdcf
feat: add checking func to discard all CDN domains owned by Ad-Shield
piquark6046 Jan 18, 2026
0b7640a
feat: add `IndexAdShieldDomainsFromUBO` func to refer uBO filters list
piquark6046 Jan 18, 2026
c0bf75c
feat: add `FetchAdShieldDomains` func to refer AG Base and uBO filter…
piquark6046 Jan 18, 2026
b253d9b
chore: remove unnecessary import
piquark6046 Jan 18, 2026
4be8bd9
ci: run ESLint workflow for all branches
piquark6046 Jan 18, 2026
5a5ad11
chore: rename `FetchAdShieldDomainsFromFiltersLists`
piquark6046 Jan 18, 2026
79f1ab5
feat: add `FetchAdShieldDomains` func to refer all references
piquark6046 Jan 18, 2026
5dab3b1
feat: provide `CustomDefinedMatches` Set
piquark6046 Jan 18, 2026
b1c9c84
feat: add building cache for caching remote domains
piquark6046 Jan 18, 2026
9fb4d9f
feat: create `CreateBanner` func
piquark6046 Jan 18, 2026
33f3ae6
fix: path is not resolved correctly if `npm run` is used
piquark6046 Jan 18, 2026
3b37419
feat: use new builder
piquark6046 Jan 18, 2026
4f8b980
chore: add `SubscriptionUrl` customization for debugging
piquark6046 Jan 19, 2026
efef1c4
fix: chokidar does not built-in glob support
piquark6046 Jan 19, 2026
b12ec19
fix: typo
piquark6046 Jan 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
sources/src/#generated-*.ts
sources/src/#generated-*.ts
.buildcache
32 changes: 32 additions & 0 deletions builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@filteringdev/tinyshield-builder",
"private": true,
"type": "module",
"scripts": {
"lint": "tsc --noEmit && eslint **/*.ts",
"build": "tsx source/build.ts",
"debug": "tsx source/debug.ts",
"cache": "tsx source/cache.ts",
"clean": "rm -rf dist && rm -rf .buildcache"
},
"dependencies": {
"@types/node": "^24.10.8"
},
"devDependencies": {
"@adguard/agtree": "^3.4.3",
"@npmcli/package-json": "^7.0.4",
"@types/npmcli__package-json": "^4.0.4",
"@types/semver": "^7.7.1",
"@typescriptprime/parsing": "^1.0.4",
"@typescriptprime/securereq": "^1.0.1",
"chokidar": "^5.0.0",
"esbuild": "^0.27.2",
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The esbuild version 0.27.2 appears to be outdated. As of January 2025, esbuild was at version 0.24.x or higher. Consider updating to a more recent version.

Suggested change
"esbuild": "^0.27.2",
"esbuild": "^0.24.0",

Copilot uses AI. Check for mistakes.
"eslint": "^9.39.2",
"semver": "^7.7.3",
"tldts": "^7.0.19",
"tsx": "^4.21.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.53.0",
"zod": "^4.3.5"
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion builder.ts → builder/source/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ let AttachHeaderPath = `/tmp/${crypto.randomUUID()}`
Fs.writeFileSync(AttachHeaderPath, ConvertedHeader, { encoding: 'utf-8', mode: 0o700 })
console.log('Written temporary header file to:', AttachHeaderPath)
await ESBuild.build({
entryPoints: ['./sources/src/index.ts'],
entryPoints: ['./sources/index.ts'],
bundle: true,
minify: BuildType === 'production',
define: {
Expand Down
38 changes: 38 additions & 0 deletions builder/source/references/iabsellers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as Zod from 'zod'
import { HTTPSRequest } from '@typescriptprime/securereq'


const IABSellersJsonURL = 'https://info.ad-shield.io/sellers.json'

export async function FetchIABSellersJsonData(): Promise<string[]> {
const IABSellersJsonResponse: { StatusCode: number, Headers: Record<string, string | string[]>, Body: unknown } = await HTTPSRequest(new URL(IABSellersJsonURL), { ExpectedAs: 'JSON' })
let IABSellersJsonData =IABSellersJsonResponse.Body as {
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after the equals sign. Should be "let IABSellersJsonData = IABSellersJsonResponse.Body".

Suggested change
let IABSellersJsonData =IABSellersJsonResponse.Body as {
let IABSellersJsonData = IABSellersJsonResponse.Body as {

Copilot uses AI. Check for mistakes.
// eslint-disable-next-line @typescript-eslint/naming-convention
sellers: Array<{
// eslint-disable-next-line @typescript-eslint/naming-convention
seller_id: number,
// eslint-disable-next-line @typescript-eslint/naming-convention
seller_type: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
name: string,
// eslint-disable-next-line @typescript-eslint/naming-convention
domain: string
}>
}
IABSellersJsonData = await Zod.object({
sellers: Zod.array(Zod.object({
seller_id: Zod.number(),
seller_type: Zod.string(),
name: Zod.string(),
domain: Zod.string().refine(D => {
try {
new URL(`https://${D}`)
} catch {
return false
}
return true
})
}))
}).parseAsync(IABSellersJsonData)
return [...new Set(IABSellersJsonData.sellers.map(S => S.domain))]
}
33 changes: 33 additions & 0 deletions builder/source/utils/http-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as HTTP from 'node:http'
import * as Fs from 'node:fs'

function IsLoopBack(IP: string) {
return IP === '127.0.0.1' || IP === '::1' || IP === '::ffff:127.0.0.1'
}

export function RunDebugServer(Port: number, FileName: string[], ShouldPreventHTTPResponse: boolean) {
const HTTPServer = HTTP.createServer((Req, Res) => {
if (!FileName.includes(Req.url?.substring(1) || '')) {
Res.writeHead(404)
Res.end()
return
} else if (!IsLoopBack(Req.socket.remoteAddress)) {
Res.writeHead(403)
Res.end()
return
} else if (ShouldPreventHTTPResponse || !Fs.existsSync(`${process.cwd()}/dist/${Req.url?.substring(1)}`)) {
Comment thread Fixed
Res.writeHead(503)
Res.end('File not built yet.')
return
}

const Content = Fs.readFileSync(`${process.cwd()}/dist/${Req.url?.substring(1)}`, 'utf-8')
Comment thread Fixed
Res.writeHead(200, {
'content-type': 'application/javascript; charset=utf-8',
'content-length': new TextEncoder().encode(Content).byteLength.toString()
})
Res.end(Content)
})

HTTPServer.listen(Port)
}
7 changes: 7 additions & 0 deletions builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"include": [
"source/**/*.ts",
"test/**/*.ts"
]
}
23 changes: 6 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build:userscript": "tsx builder.ts -- production",
"build": "npm run build:interface && npm run build:userscript",
"debug": "tsx builder.ts -- development",
"lint": "tsc --noEmit && eslint sources/**/*.ts"
"lint": "npm run lint -w builder && npm run lint -w userscript"
},
"keywords": [
"Ad-Shield"
Expand All @@ -28,20 +28,9 @@
"url": "git+https://github.com/FilteringDev/tinyShield.git"
},
"license": "MPL-2.0",
"dependencies": {
"@types/node": "^24.9.2"
},
"devDependencies": {
"@npmcli/package-json": "^7.0.4",
"@types/npmcli__package-json": "^4.0.4",
"@types/semver": "^7.7.1",
"esbuild": "^0.27.0",
"eslint": "^9.38.0",
"semver": "^7.7.3",
"tsx": "^4.21.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.2",
"zod": "^4.3.5"
},
"packageManager": "[email protected]+"
"packageManager": "[email protected]+",
"workspaces": [
"userscript",
"builder"
]
}
9 changes: 0 additions & 9 deletions sources/esbuild.inject.ts

This file was deleted.

8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"moduleResolution": "NodeNext",
"removeComments": false,
"alwaysStrict": false,
"skipLibCheck": true
"skipLibCheck": true,
"paths": {
"@builder/*": ["./builder/source/*"],
"@userscript/*": ["./userscript/source/*"],
"@root/*": ["./source/*"],
"@reporoot/*": ["./*"]
}
}
}
11 changes: 11 additions & 0 deletions userscript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@filteringdev/tinyshield-userscript",
"private": true,
"type": "module",
"scripts": {
"lint": "tsc --noEmit && eslint **/*.ts"
},
"devDependencies": {
"@types/web": "^0.0.317"
}
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sources/interface.ts → userscript/source/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* - See Git history at https://github.com/FilteringDev/tinyShield for detailed authorship information.
*/

export { RunTinyShieldUserscript } from './src/index.js'
export { RunTinyShieldUserscript } from './index.js'
File renamed without changes.
6 changes: 6 additions & 0 deletions userscript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"include": [
"source/**/*.ts"
]
}