Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
feat: downloading remote resources from Ad-Shield server
Browse files Browse the repository at this point in the history
  • Loading branch information
piquark6046 committed Feb 1, 2024
1 parent 6a69210 commit 02b41b1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
14 changes: 8 additions & 6 deletions microShield.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microshield",
"version": "3.13.3",
"version": "3.14.0",
"description": "",
"type": "module",
"scripts": {
Expand Down
4 changes: 3 additions & 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/gh/List-KR/microShield@latest/microShield.user.js
// @license Apache-2.0
//
// @version 3.13.3
// @version 3.14.0
// @author PiQuark6046 and contributors
//
// @match *://algumon.com/*
Expand Down Expand Up @@ -98,6 +98,8 @@
// @match *://*.alle-tests.nl/*
// @match *://allthetests.com/*
// @match *://*.allthetests.com/*
// @match *://issuya.com/*
// @match *://*.issuya.com/*
//
// @description microShield allows AdGuard, uBlock Origin, Brave and ABP to resist against Ad-Shield widely.
// @description:ko microShield는 AdGuard, uBlock Origin, Brave and ABP가 애드쉴드에 널리 저항할 수 있도록 합니다.
Expand Down
3 changes: 2 additions & 1 deletion sources/src/__generated__/ztinywave.cache.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions sources/src/loaders/ztinywave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Data = Array<{tags: string}>;

const debug = createDebug('[microShield:tinywave]');

const decode = (payload: string) => {
const decode = (payload: string, scriptURL: string) => {
const id = payload.slice(0, 4);
const key = cache.source.find(store => store.id === id);

Expand All @@ -28,7 +28,7 @@ const decode = (payload: string) => {

let mode = 0;

const data = payload
let data = payload
.slice(4)
.split('')
.map(char => {
Expand Down Expand Up @@ -70,6 +70,12 @@ const decode = (payload: string) => {
})
.join('');

if (data.includes('resources://') && key.remoteResourceToken) {
debug('downloading remote resource from Ad-Shield is required', data);
const scriptHostname = new URL(scriptURL.startsWith('//') ? `https:${scriptURL}` : scriptURL).hostname;
data = data.replace(/resources:\/\/[a-zA-Z0-9-]+/, (`https://${scriptHostname}/resources/${/(?<=resources:\/\/)[a-zA-Z0-9-]+/.exec(data) as unknown as string}?token=${key.remoteResourceToken}`));
}

return JSON.parse(data) as Data;
};

Expand Down Expand Up @@ -127,7 +133,7 @@ const extract = async () => {
throw new Error('DEFUSER_SHORTWAVE_TARGET_NOT_FOUND');
}

return decode(source.data);
return decode(source.data, source.script);
};

export const tinywave = async () => {
Expand Down

0 comments on commit 02b41b1

Please sign in to comment.