我正在尝试使用reg表达式来替换.com之类的url,例如本地主机。我不是一个有表情的大师,因此有很多麻烦这样做。我们可以为我们的localhost配置Chrome扩展程序,并将所有网址交换为指向本地主机进行调试。所以表达式需要找到类似下面的内容:
*。com / - >并且保持不变,但直到.com与我们的临时字符串值交换。
提前致谢
答案 0 :(得分:1)
如果你想使用chrome扩展,那么*是有效的
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
details.url = "http://localhost";
},
{urls: ["*://*.*.com/*"]}, //could also be urls: ["*://my.host.com/*"]
//also if you want to change all urls you can use ["<all_urls>"]
["blocking"]);
答案 1 :(得分:1)