简体   繁体   English

使用Chrome扩展程序来阻止网页加载?

[英]Using a Chrome Extension to stop a webpage from loading?

My eventual goal is to find all resources that the webpage is attempting to load, stop them from loading, and then list them (so that the user can see what the webpage tried to load). 我最终的目标是找到该网页尝试加载的所有资源,停止加载它们,然后列出它们(以便用户可以看到该网页尝试加载的资源)。 Can anyone help me get started with the necessary JavaScript that I'll need to both stop the page from loading and print the resources? 谁能帮助我开始使用必要的JavaScript,以阻止页面加载和打印资源? I'm just kind of lost on what the first step should be. 我只是迷失了第一步。

Take a look at webrequest for chrome extensions: https://developer.chrome.com/extensions/webRequest 看看chrome扩展的webrequest: https : //developer.chrome.com/extensions/webRequest

I would suggest to create a callback for onBeforeRequest() and then checking what resources are being fetched and loaded. 我建议为onBeforeRequest()创建一个回调,然后检查正在获取和加载哪些资源。

You can cancel a particular web request from this callback. 您可以从此回调中取消特定的Web请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM