87

I am currently analysing my page connections and I want to block some tracking scripts and other external URL calls in my network monitor inside Chrome's developer tools.

I quickly want to check how the page behaves without some libraries.

Chrome itself does not provide any functions like this and the famous blocking extensions only block URLs which the user enters manually into the navigation bar.

Alcedo_Atthis
  • 923
  • 1
  • 7
  • 6

10 Answers10

101

As pointed out by @calavera.info, @iman.Bahrampour, and @Asim K T this feature is now available in Chrome 59. You can select a URL or domain to block in the Network panel. See this release note and these Screenshots where the StackOverflow logo has been blocked from this page. @iman.Bahrampour also shares two extensions below that will also do this ("HTTP Request Blocker" and "Request Blocker").

StackOverflow logo blocked Adding a new block

abd3721
  • 1,374
  • 1
  • 11
  • 10
  • With `Version 49.0.2575.0 canary (64-bit)` I don't see this option :( – orique Nov 26 '15 at 16:06
  • 2
    Yeah, they keep changing where they're putting it, and pulling it out again. It appeared briefly as an option along with Console in the bottom panel, but it was buggy :-) Apparently they're still trying to get this right. – abd3721 Dec 01 '15 at 19:50
  • How to do you enable this experimental feature? – Samar Panda Jun 06 '16 at 04:34
  • @SamarPanda - Chrome Canary is a preview version of Chrome that stays a couple of versions ahead of the released version. https://www.google.com/chrome/browser/canary.html – abd3721 Jun 07 '16 at 18:01
  • @abd3721 Yes, i know that. Wondering as i don't see this option in Chrome 51.0.2704.84 (64-bit) or Canary 53.0.2762.0 canary (64-bit). – Samar Panda Jun 09 '16 at 04:43
  • it's no where to be found now – Muhammad Umer Jul 25 '16 at 19:20
  • FYI it's been removed... you can star this issue if you want this feature back: https://bugs.chromium.org/p/chromium/issues/detail?id=542285 – Kayce Basques Aug 04 '16 at 15:26
  • how I can always block domains not one time? – Jlil Oct 14 '17 at 07:37
  • Blocking requests doesn't seem to work for HTTP 302 Redirects? – sgdesmet Jul 23 '19 at 11:19
  • Mention if this only works within Developer Tools, or even keeps on working on other tabs. And if it is remembered the next time we open the browser. – Dan Jacobson Dec 06 '19 at 01:21
  • If you need to block all js, can go to "Network request blocking" tab and click "+", then add pattern "*.js" – Omar Shishani Sep 08 '22 at 01:43
24

As abd3721 mentioned this is available directly within chrome DevTools (You don't need to be on canary anymore), however it is still behind a flag and in the hidden experimental features menu. As of the time of this comment, Chrome stable is on version 53.

To enable it, open this link and click the enable link under the appropriate flag: chrome://flags/#enable-devtools-experiments

Then in DevTools open up the settings panel(F1) and click on the experiments tab.

This lists all currently available DevTools experiments but it is still in yet another hidden set of features.

Press Shift 6 times while in the experiments tab to show even more hidden features, one of them will be Request Blocking.

NOTE: These features are considered experimental and may be buggy or incomplete. Use with caution.

Community
  • 1
  • 1
synaestheory
  • 253
  • 2
  • 6
19

For blocking requests in google chrome you have 3 options:

1. Google Chrome with pattern matching:

In network tab, right click on request and then select block request URL

block request for chrome

There is a plus sign that adds patterns for blocking requests

set pattern for blocked request

For example I have 7 request URLs:

  1. http://www.test.com?userid=5
  2. http://www.test.com?username=username
  3. http://www.test.com?email=email
  4. http://www.test.com?name=x
  5. http://www.test.com?family=q
  6. http://www.test.com?family=y
  7. http://www.test.com?family=z

I can block requests that have a specific pattern by adding a pattern(for example the pattern *family* blocks 3 below requests):

  1. http://www.test.com?family=q
  2. http://www.test.com?family=y
  3. http://www.test.com?family=z

Be careful! Because patterns are case sensitive

2. HTTP Request Blocker extension:

HTTP Request Blocker

This extension has pattern matching for blocking requests:

Match patterns

3. Request blocker extension:

This is a useful extension that has pattern matching for blocking requests.

The most useful features of this request blocker are importing and exporting lists for using by other People.

block request with Request blocker extension

For exporting a list and using in another computer(or future used): click on Direction down and select Export.

enter image description here

Open the exported list with import list button.

Good Luck

Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
  • Current URLs for above items apparently are: https://github.com/wolfascu/ChromeHttpRequestBlocker https://github.com/gera2ld/request-x – Dan Jacobson Dec 24 '19 at 00:44
17

From Chrome 59 you can block specific requests from Network tab of developer tools itself.

https://developers.google.com/web/updates/2017/04/devtools-release-notes#block-requests

Right-click on the request in the Network panel and select Block Request URL. A new Request blocking tab pops up in the Drawer, which lets you manage blocked requests.

enter image description here

Asim K T
  • 16,864
  • 10
  • 77
  • 99
7

This is now achievable in Chrome 59 developer tools by blocking respective requests: https://developers.google.com/web/updates/2017/04/devtools-release-notes#block-requests. With this approach it is somehow difficult to turn off all the stylesheets, but it's easier to turn off just the most annoying ones.

calavera.info
  • 1,170
  • 2
  • 15
  • 30
5

As for Google Chrome 94, it's possible to exclude network activity for entire domain:

1. Go to "Network" panel of DevTools:

"Network" panel of Chrome DevTools

2. Rigth click on item of domain you want to block, click on "Block request domain" in the context menu:

context menu of Network item

3. Type "status-code:0" into "Filter" and click on "Invert" checkbox:

fitering of Network items

To manage blocked domains, press ESC button when in DevTools, and click on "Network request blocking" tab in the bottom panel:

Network request blocking

userlond
  • 3,632
  • 2
  • 36
  • 53
0

Will changing host file help. Your system (windows, linux, mac) all check host before requesting DNS lookup. I use it when I wan tot block some slow advertisers.

windows: c:\Windows\system32\drivers\etc\hosts

linux & mac /etc/hosts

* BE VERY CAREFUL TO MAKE BACK UPS *

terary
  • 940
  • 13
  • 30
0

An existing bug report is requesting this feature. You can star that issue to show support for it being added.

Garbee
  • 10,581
  • 5
  • 38
  • 41
0

Well, i have been looking for an answer for this too, as I had this issue of choices by counterfeit, and nothing seemed to work for me. But then I tried to analyze the requests and other things until I figured out, that there was this site which was loading ads onto my pages and redirecting me to advertisements. And also changing the google search bar on new tabs to some unknown search engine. I was able to temporarily block the request on one page. but after opening a new tab, the ads would appear again.

So googling for request blocker, I came up with a chrome extension "HTTP Request Blocker" and added the address which was causing all the crazy ads, has now solved the problem fully.

I hope it will be of help to you too or anyone else.

Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
ali_0
  • 1
0

In the original question, the author states:

the famous blocking extensions only block URLs which the user enters manually into the navigation bar.

This is no longer the case. I have really enjoyed using mokku, which can intercept and mock all types of requests. You can specify what the status code should be, so it will definitely solve this problem as well as adding other functionality that is helpful. It works by another tab in the chrome dev tools. Here is a link to the extension: https://chrome.google.com/webstore/detail/mokku-mock-api-calls-seam/llflfcikklhgamfmnjkgpdadpmdplmji?hl=en