Skip to content

Commit c138eb3

Browse files
committed
up
1 parent 3062daf commit c138eb3

4 files changed

Lines changed: 555 additions & 254 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
raw_data/*
2+
data_all/*
23
node_modules/*
34
Reference/*
45
package-lock.json
@@ -10,4 +11,5 @@ make.bat
1011
WebDataScope.zip
1112
WQ数据分析插件使用教程.docx
1213
.DS_Store
13-
WebData.zip
14+
WebData.zip
15+
WebDataRAW.zip

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "WorldQuant Scope",
44
"description": "WorldQuant Scope is a browser extension that provides a set of tools to help you navigate the WorldQuant platform.",
5-
"version": "0.10.8",
5+
"version": "0.10.9",
66
"author": "zhangkaihua@buaa.edu.cn",
77
"icons": {
88
"128": "img/logo.png"

src/scripts/background.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import './lib/msgpack.min.js';
77
const dataSetListUrl = chrome.runtime.getURL(`data/dataSetList.json`);
88
const dataInfoUrl = chrome.runtime.getURL(`data/oth/info_data.bin`);
99
let dataSetList = null; // 定义全局变量
10-
let dataInfo = null;
1110
const REPO_OWNER = "zhangkaihua88";
1211
const REPO_NAME = "WebDataScope";
1312
const CHECK_INTERVAL = 24 * 60 * 60 * 1000; // 24小时检查一次
@@ -168,7 +167,6 @@ function broadcastRequest(rec) {
168167
});
169168
}
170169

171-
172170
// 版本比较函数
173171
function compareVersions(v1, v2) {
174172
const parts1 = v1.split('.').map(Number);
@@ -264,23 +262,24 @@ async function injectionDataFlagScript(tabId, tab) {
264262
if (dataSetList === null) {
265263
dataSetList = await getDataSetList();
266264
}
267-
if (dataInfo === null) {
268-
const response = await fetch(dataInfoUrl);
269-
const arrayBuffer = await response.arrayBuffer();
270-
// pako 为 UMD 版本,已挂载到 globalThis;确保输入为 Uint8Array
271-
const inflatedData = globalThis.pako.inflate(new Uint8Array(arrayBuffer));
272-
dataInfo = globalThis.msgpack.decode(new Uint8Array(inflatedData));
273-
}
265+
// 获取当前扩展版本号,用于缓存版本控制
266+
const version = chrome.runtime.getManifest().version;
274267

275-
console.log('Decoded IS/OS data:', dataInfo);
276268
try {
269+
// 必须注入 pako 和 msgpack 供 content script 使用
277270
chrome.scripting.executeScript({
278271
target: { tabId: tabId },
279-
files: ["src/scripts/utils.js", 'src/scripts/dataFlag.js'],
272+
files: [
273+
"src/scripts/lib/pako.min.js",
274+
"src/scripts/lib/msgpack.min.js",
275+
"src/scripts/utils.js",
276+
"src/scripts/dataFlag.js"
277+
],
280278
}, () => {
281279
chrome.scripting.executeScript({
282280
target: { tabId },
283-
args: [dataSetList, dataInfo, tab.url],
281+
// 仅传递必要的元数据,不传递巨大的 dataInfo 对象
282+
args: [dataSetList, dataInfoUrl, version, tab.url],
284283
func: (...args) => dataFlagFunc(...args),
285284
});
286285
});

0 commit comments

Comments
 (0)