Skip to content

Instantly share code, notes, and snippets.

@fny
Created November 11, 2013 01:25
Show Gist options
  • Select an option

  • Save fny/7406299 to your computer and use it in GitHub Desktop.

Select an option

Save fny/7406299 to your computer and use it in GitHub Desktop.
Chrome extension to block Readrboard's engage.js for performance testing.
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
// Visible in the extension's generated background page
console.log("Script blocked: " + info.url);
return {cancel: true};
},
{
urls: ["*://*.readrboard.com/static/engage.js"],
types: ["script"],
},
["blocking"]
);

This Chrome extension blocks Readrboard's engage.js.

To install, clone this gist or save the files in a new directory. Then visit Chrome's extension dashboard (chrome://extensions/), enable developer mode, and install the unpacked extension.

You can modify the URLs by modifying the urls array in background.js. See Chrome's Match Patterns for valid URL patterns. Note you'll also need to add/update the respective URL in the permissions section of manifest.json to allow the extension to block the scripts from the specified addresses.

See the documentation for Chrome's webRequest.onBeforeRequest for more information.

{
"name": "ReadrBlock",
"version": "1.0",
"manifest_version": 2,
"background": {
"scripts": ["background.js"]
},
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*.readrboard.com/*"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment