Skip to content

Commit

Permalink
Merge pull request #105 from sve1r/feat/monthly
Browse files Browse the repository at this point in the history
June Update
  • Loading branch information
sve1r authored Jun 22, 2024
2 parents 916d4c0 + c4f3c79 commit 24a43ac
Show file tree
Hide file tree
Showing 7 changed files with 107,194 additions and 106,869 deletions.
4 changes: 3 additions & 1 deletion Rewrite/AdBlock/LittleRedBook.adblock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// @Contribute https://t.me/ddgksf2013_bot
// @MainFunction 去开屏、瀑布流、启动服务广告及一些隐私、广告、青少年请求,去水印及功能增强
// @Feedback 📮 [email protected] 📮
// @UpdateTime 2024-03-24
// @UpdateTime 2024-06-01
// @Function 去广告配置(自用,不定期更新)
// @Suitable 自行观看“# > ”注释内容
// @Attention 如需引用请注明出处,谢谢合作!
Expand All @@ -18,6 +18,8 @@

hostname = edith.xiaohongshu.com, www.xiaohongshu.com, pages.xiaohongshu.com, referee.xiaohongshu.com

# > 小红书_搜索结果推荐广告@ddgksf2013
^https?:\/\/edith\.xiaohongshu\.com\/api\/sns\/v\d+\/search\/notes\? url script-response-body https://rules-for-qx.sveir.xyz/Scripts/AdBlock/LittleRedBook/LittleRedBook.min.js
# > 小红书_视频播放页商品推广@ddgksf2013
^https?:\/\/edith\.xiaohongshu\.com\/api\/sns\/v\d\/note\/widgets url script-response-body https://rules-for-qx.sveir.xyz/Scripts/AdBlock/LittleRedBook/LittleRedBook.min.js
# > 小红书_短视频流去水印+强制开启保存功能@ddgksf2013
Expand Down
140 changes: 140 additions & 0 deletions Rewrite/Services/Google/GoogleRecaptcha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/********************************
Google搜索人机验证解决方案
搜索内容时遇到人机验证立即并发使用多个代理策略、策略组尝试搜索内容,并返回最优结果。
脚本作者:@NobyDa
更新时间:2024/05/19
平台兼容:Surge(iOS4.9.3+/macOS4.2.3+) / QuantumultX(1.0.26+) / Loon(3.1.9[694]+)
可在 BoxJs(低优先级)、Surge模块参数、Loon插件参数中填写筛选的代理策略、策略组的正则表达式。
所有代理策略、策略组至多筛选、使用20个,可在BoxJs中测试匹配的策略,不筛选则表示随机使用。
注意:Surge由于策略架构问题,正则表达式筛选的"代理策略"不包含"外部代理策略";
QuantumultX、Loon则无此限制,正则表达式可筛选所有"策略组"内的"代理策略"。
*********************************
Surge(iOS 5.9.0+/macOS 5.5.0+) 模块:
https://raw.githubusercontent.com/NobyDa/Script/master/Surge/Module/GoogleCAPTCHA.sgmodule
*********************************
QuantumultX(1.0.26+) 重写资源引用:
https://raw.githubusercontent.com/NobyDa/Script/master/QuantumultX/Snippet/GoogleCAPTCHA.snippet
*********************************
Loon(3.1.9[694]+) 插件:
https://raw.githubusercontent.com/NobyDa/Script/master/Loon/Loon_Google_CAPTCHA.plugin
*********************************
BoxJs 订阅地址:
https://raw.githubusercontent.com/NobyDa/Script/master/NobyDa_BoxJs.json
*********************************/

const $ = new NobyDa_Tools();
$.ret = {};

!(async () => {
if (($response.status || $response.statusCode) == 200) return;
const req = JSON.parse(JSON.stringify($request));
const policy = await $.policy();
const regexText = (typeof $argument == 'string' && $argument) ||
$.data.read('GOOGLE_CAPTCHA_REGEX') || // loon plugin args.
JSON.parse($.data.read('GOOGLE_CAPTCHA') || '{}').Regex || ''; // empty = all
const selected = [...policy.group, ...policy.proxy]
.filter((n) => n && new RegExp(regexText).test(n))
.sort(() => Math.random() - 0.5).slice(0, 20); // prevent too many TCP, filtered to random select up to 20
console.log(`[INFO]: Use policy ${JSON.stringify(selected, null, 2)}`);
await Promise.any([
...selected.map(
(i) => new Promise((r, e) => {
if (req.headers['User-Agent']) req.headers.Cookie = `${Math.random()}`; // prevent set-cookie
if (req.headers['user-agent']) req.headers.cookie = `${Math.random()}`; // h2
$.http[req.method.toLowerCase()]({
policy: i, node: i, opts: { policy: i }, // policy:surge, node:loon, opts:qx
...req
}).then((v) => {
if (v.status == 200) {
r({ policy: i, body: { ...v, status: $.isQuanX ? 'HTTP/1.1 200' : 200 } })
} else if (v.status == 429) {
e(console.log(`[INFO]: Policy "${i}" need to CAPTCHA`))
} else {
e(console.log(`[INFO]: Policy "${i}" unknown resp status "${v.status}"`))
}
}).catch((err) => e(console.log(`[ERROR]: ${err}`)))
})
)
]).then((data) => {
$.ret = data.body;
console.log(`[INFO]: Use data from "${data.policy}"`);
})
})()
.catch((err) => console.log(`[ERROR]: ${(err && err.message) || err}`))
.finally(() => $done($.ret));


function NobyDa_Tools() {
this.isLoon = typeof $loon !== "undefined";
this.isQuanX = typeof $configuration !== 'undefined';
this.isSurge = typeof $environment !== 'undefined' && $environment['surge-version'];
this.isNode = typeof module !== 'undefined' && !!module.exports;
this.http = Object.fromEntries(
["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "PATCH"].map(
(m) => [m.toLowerCase(), (opts) => {
if (this.isQuanX) return new Promise((resolve, reject) => {
$task.fetch({ method: m, ...opts })
.then((r) => resolve({
status: r.statusCode, headers: r.headers, body: r.body,
}), e => reject(e.error))
});
if (this.isSurge || this.isLoon || this.isNode) return new Promise((resolve, reject) => {
const request = this.isNode ? require("request") : $httpClient;
request[m.toLowerCase()](opts, (e, r, b) => {
if (e) reject(e);
else resolve({ status: r.status || r.statusCode, headers: r.headers, body: b })
})
});
}]
)
);
this.policy = () => {
if (this.isSurge) return new Promise((r) => {
$httpAPI("GET", "v1/policies", null, (v) => r({
proxy: v.proxies,
group: v['policy-groups']
}))
});
if (this.isQuanX) return new Promise((r) => {
$configuration.sendMessage({
action: "get_customized_policy"
}).then(b => r({
proxy: Object.keys(b.ret)
.reduce((t, i) => [...new Set([...t, ...b.ret[i].candidates || []])], [])
.filter((v) => !b.ret[v] && !['direct', 'proxy', 'reject'].includes(v)),
group: Object.keys(b.ret)
}), () => r({}));
});
if (this.isLoon) return new Promise(async (r1) => {
const config = JSON.parse($config.getConfig());
const groupData = await Promise.all(config['all_policy_groups'].map((i) => new Promise((r2) => {
$config.getSubPolicies(i, (b) => { r2(JSON.parse(b || '[]')) })
})));
r1({
proxy: groupData.reduce((t, i) => [...new Set([...t, ...i.filter((v) => {
return v.type == 'node' && !config['all_buildin_nodes'].includes(v.name)
}).map((n) => n.name)])], []),
group: config['all_policy_groups']
})
});
};
this.data = Object.fromEntries(['read', 'write'].map(
(i) => [i, (v1, v2) => {
if (i === 'write') {
if (this.isSurge || this.isLoon) return $persistentStore.write(v1, v2);
if (this.isQuanX) return $prefs.setValueForKey(v1, v2);
} else if (i === 'read') {
if (this.isSurge || this.isLoon) return $persistentStore.read(v1);
if (this.isQuanX) return $prefs.valueForKey(v1);
}
}]
));
}
1 change: 1 addition & 0 deletions Rewrite/Services/Google/GoogleRecaptcha.min.js

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

12 changes: 12 additions & 0 deletions Rewrite/Services/Google/GoogleRecaptcha.rewrite
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# QuantumultX 远程重写配置片段

# Google搜索人机验证解决方案
# Google搜索内容时并发使用多个代理策略、策略组尝试搜索内容,并返回最优结果。具体细节可查看脚本注释。

# 脚本:https://raw.githubusercontent.com/NobyDa/Script/master/Surge/JS/Google_CAPTCHA.js
# 片段:https://raw.githubusercontent.com/NobyDa/Script/master/QuantumultX/Snippet/GoogleCAPTCHA.snippet

hostname = www.google.com*

^https:\/\/www\.google\.com(?:\.[a-z]+|)\/(?:search\?(?:|.+?&)q=|$) url script-response-body https://rules-for-qx.sveir.xyz/Rewrite/Services/Google/GoogleRecaptcha.min.js

Loading

0 comments on commit 24a43ac

Please sign in to comment.