79 lines
2.7 KiB
JavaScript
79 lines
2.7 KiB
JavaScript
/**
|
|
* 孚盟MX API 抓取脚本
|
|
* 使用方法:
|
|
* 1. 登录 https://www.fumamx.com/#/login
|
|
* 2. 按 F12 打开开发者工具
|
|
* 3. 切换到 Console 面板
|
|
* 4. 粘贴此脚本并回车
|
|
* 5. 在页面上正常操作(点客户、邮件等模块)
|
|
* 6. 所有 API 请求会被记录并导出
|
|
*/
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
window.fumamxAPIs = window.fumamxAPIs || [];
|
|
|
|
// 拦截 fetch
|
|
const originalFetch = window.fetch;
|
|
window.fetch = function(...args) {
|
|
const url = args[0];
|
|
const options = args[1] || {};
|
|
|
|
if (typeof url === 'string' && (url.includes('/api/') || url.includes('/rest/') || url.includes('/v1/'))) {
|
|
const record = {
|
|
method: options.method || 'GET',
|
|
url: url,
|
|
headers: options.headers,
|
|
body: options.body,
|
|
timestamp: new Date().toISOString()
|
|
};
|
|
window.fumamxAPIs.push(record);
|
|
console.log('📡 API:', record.method, url);
|
|
}
|
|
|
|
return originalFetch.apply(this, args);
|
|
};
|
|
|
|
// 拦截 XMLHttpRequest
|
|
const originalOpen = XMLHttpRequest.prototype.open;
|
|
const originalSend = XMLHttpRequest.prototype.send;
|
|
|
|
XMLHttpRequest.prototype.open = function(method, url, ...args) {
|
|
this._fumamxMethod = method;
|
|
this._fumamxUrl = url;
|
|
return originalOpen.call(this, method, url, ...args);
|
|
};
|
|
|
|
XMLHttpRequest.prototype.send = function(body) {
|
|
const url = this._fumamxUrl;
|
|
if (typeof url === 'string' && (url.includes('/api/') || url.includes('/rest/') || url.includes('/v1/'))) {
|
|
const record = {
|
|
method: this._fumamxMethod,
|
|
url: url,
|
|
body: body,
|
|
timestamp: new Date().toISOString()
|
|
};
|
|
window.fumamxAPIs.push(record);
|
|
console.log('📡 API:', record.method, url);
|
|
}
|
|
return originalSend.call(this, body);
|
|
};
|
|
|
|
// 导出功能
|
|
window.exportFumamxAPIs = function() {
|
|
const data = JSON.stringify(window.fumamxAPIs, null, 2);
|
|
const blob = new Blob([data], {type: 'application/json'});
|
|
const url = URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = 'fumamx_apis.json';
|
|
a.click();
|
|
URL.revokeObjectURL(url);
|
|
console.log('✅ 已导出 ' + window.fumamxAPIs.length + ' 个 API 端点到 fumamx_apis.json');
|
|
};
|
|
|
|
console.log('✅ 孚盟MX API 抓取器已启动');
|
|
console.log('💡 操作页面后,在控制台运行 exportFumamxAPIs() 导出结果');
|
|
})();
|