Skip to content

Instantly share code, notes, and snippets.

@concise
Created May 21, 2013 17:29
Show Gist options
  • Save concise/5621609 to your computer and use it in GitHub Desktop.
Save concise/5621609 to your computer and use it in GitHub Desktop.
Try to block annoying embedded ads in YouTube videos.
chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) {
if (details.url.indexOf('googlesyndication.com/pagead/show_ads.js') !== -1 ||
details.url.indexOf('googlesyndication.com/pagead/show_companion_ad.js') !== -1 ||
details.url.indexOf('s.ytimg.com/yts/swfbin/ad') !== -1) {
return {cancel: true};
}
},
{
urls: [
"*://*.googlesyndication.com/*",
"*://*.ytimg.com/*"
]
},
["blocking", "requestHeaders"]
);
{
"version": "0.0.1",
"manifest_version": 2,
"name": "Block Youtube Ads",
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*.googlesyndication.com/*",
"*://*.ytimg.com/*"
],
"background": {
"scripts": ["block-youtube-ads.js"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment