Skip to content

Instantly share code, notes, and snippets.

@davlgd
Last active September 10, 2018 08:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davlgd/b1d63af28be8dc0fe55668d3474b57b0 to your computer and use it in GitHub Desktop.
Save davlgd/b1d63af28be8dc0fe55668d3474b57b0 to your computer and use it in GitHub Desktop.
Bad Search Engine Blocker - Projet final
chrome.webRequest.onBeforeRequest.addListener(function (request) {
const askedURL = new URL(request.url);
const keywords = askedURL.searchParams.get("q");
if (/bing.|google.|yahoo./.test(askedURL.hostname))
{
const destinationUrl = (keywords) ? "https://www.framabee.org?q=" + keywords : "https://www.framabee.org";
return { redirectUrl: destinationUrl };
}
},
{ urls: ["<all_urls>"] }, ["blocking"]);
{
"manifest_version": 2,
"name": "Bad Search Engine Blocker",
"description": "Une extension pour bloquer les moteurs de recherche qui ne respectent pas la vie privée",
"version": "0.1",
"permissions": [
"webRequest",
"webRequestBlocking",
"<all_urls>"
],
"background": {
"scripts": ["background.js"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment