Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p> This can be done quite easily via a Chrome extension, using the <a href="https://developer.chrome.com/extensions/webRequest" rel="noreferrer"><code>webRequest</code></a> API. The example below blocks <strong>all</strong> external scripts. Replace <code>&lt;all_urls&gt;</code> with a <a href="https://developer.chrome.com/extensions/match_patterns" rel="noreferrer">more specific pattern</a>. For very dynamic patterns, you can modify the <a href="https://developer.chrome.com/extensions/webRequest#event-onBeforeRequest" rel="noreferrer"><code>chrome.webRequest.onBeforeRequest</code></a> event listener.</p> <ol> <li>Create a new directory.</li> <li>Create the files below.</li> <li>Load the unpacked extension in Developer mode via <code>chrome://extensions/</code></li> </ol> <h2><code>background.js</code></h2> <pre class="lang-js prettyprint-override"><code>chrome.webRequest.onBeforeRequest.addListener( function() { return {cancel: true}; }, { urls: ["&lt;all_urls&gt;"], // Change this to a more specific pattern types: ["script"] }, ["blocking"] ); </code></pre> <h2><code>manifest.json</code></h2> <pre class="lang-js prettyprint-override"><code>{ "name": "Block request", "version": "1.0", "manifest_version": 2, "background": { "scripts": ["background.js"] }, "permissions": [ "webRequest", "webRequestBlocking", "&lt;all_urls&gt;" ] } </code></pre> <p>PS. Keep an eye on the <a href="https://developer.chrome.com/extensions/declarativeWebRequest" rel="noreferrer"><code>chrome.declarativeWebRequest</code></a> API. At the time of writing, it's in the beta/dev channel, but when you read this answer. This new API is more efficient than the <code>webRequest</code> API, and allows one to use <a href="https://developer.chrome.com/extensions/event_pages" rel="noreferrer">event pages</a> instead of background pages (the <code>webRequest</code> API cannot be used on event pages).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload