-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【bug已确认】js大文件无法替换成功 #39
Comments
问题原因已找到:background.js中以下代码把替换的本地文件用data标签输出在浏览器的地址栏并redirect重定向过去。 哪位大大可以解决下这个问题?? chrome.webRequest.onBeforeRequest.addListener(function (details) {
var url = details.url;
for (var i = 0, len = ReResMap.length; i < len; i++) {
var reg = new RegExp(ReResMap[i].req, 'gi');
if (ReResMap[i].checked && typeof ReResMap[i].res === 'string' && reg.test(url)) {
if (!/^file:\/\//.test(ReResMap[i].res)) {
// return ReResMap[i].type === 'file' ?
// {redirectUrl: ReResMap[i].res} :
// {redirectUrl: url.replace(reg, ReResMap[i].res)};
do {
url = url.replace(reg, ReResMap[i].res);
} while (reg.test(url))
} else {
// return ReResMap[i].type === 'file' ?
// {redirectUrl: getLocalFileUrl(ReResMap[i].res)} :
// {redirectUrl: getLocalFileUrl(url.replace(reg, ReResMap[i].res))};
do {
url = getLocalFileUrl(url.replace(reg, ReResMap[i].res));
} while (reg.test(url))
}
}
}
return url === details.url ? {} : { redirectUrl: url };
},
{urls: ["<all_urls>"]},
["blocking"]
); |
我看了一下,你这个bug是本地js,我本地文件替换就没成功过。 |
对的,就是本地替换存在这个bug。本来用插件就是为了方便,如果为了替换js还要另外搭建http服务器的话动作就大了,而且还涉及到CORS跨域、原站https替换成http等各种安全相关问题,处理起来很是麻烦。 希望有大佬能解决下这个bug |
试了很多遍了,发现一般的 js 小文件(几百K以内)可以成功替换,但是当 js 文件比较大(2M以上时),替换就不成功了,反复试了很多次都不成功,规则是一样的
The text was updated successfully, but these errors were encountered: