webpackJsonp检索调用库 moduleRaid
本帖最后由 empyrealtear 于 2025-1-10 03:05 编辑> 本帖最后由 empyrealtear 于 2025-1-9 20:22 编辑
> 本帖最后由 empyrealtear 于 2025-1-9 15:12 编辑
# (https://scriptcat.org/zh-CN/script-show-page/2628/)
moduleRaid可以从webpack嵌入在网站上的<code>webpackJsonp</code>函数(或类似端点)中获取模块和模块构造函数。此外,它还提供了搜索返回的模块的函数。
- 原作者github仓库:(https://github.com/pixeldesu/moduleRaid)
## 引用
你可以在油猴脚本中引入moduleRaid库,例如:
```js
// ==UserScript==
// ...
// @require https://scriptcat.org/lib/2628/6.2.0/moduleRaid.js
// @grant unsafeWindow
// ...
// ==/UserScript==
// 可在创建实例时指定检索的window对象
const mR = new ModuleRaid({ target: unsafeWindow })
```
## 例子
现在,有了可用的实例`mR`和获取中的模块,您可以使用两种可用的`find*()`方法来搜索模块!
```js
let results = mR.findModule('coolFeature')
// => 符合搜索条件的模块数组
let constRes = mR.findConstructor('_internal')
let constRes = mR.findConstructor((v) => /_internal/.test(v.toString()))
// => 符合搜索条件的构造函数/模块数组
// 设置moduleRaid后,可以监听正在加载的新模块
document.addEventListener('moduleraid:webpack-push', (e) => {
// e.detail中包含调用push()的参数
// 你的代码...
})
```
有关使用 moduleRaid 的更深入文档,可以访问 **(https://moduleraid.netlify.app/)**!
## 特别鸣谢
- (https://github.com/twilight-sparkle-irl)的[`webcrack`](https://gist.github.com/twilight-sparkle-irl/cb63762000e606e50690911cac1bcead)代码, 初始模块基于该代码编写
- (https://github.com/pedroslopez)提供的Webpack 5兼容, 本模块移植于该代码
- (https://github.com/pixeldesu)的[`moduleRaid`](https://github.com/pixeldesu/moduleRaid)库, 本调用库复制并修改于该代码 我靠!牛逼!
有人出手写这个了
@王一之 李恒道 发表于 2025-1-9 15:16
@王一之
nb 李恒道 发表于 2025-1-9 15:16
我靠!牛逼!
有人出手写这个了
只是复制了原作者的源码,把window对象改成了可以自定义的字段,原作者pixeldesu他们才牛逼{:4_93:} nb
页:
[1]