-2

How to catch search request when client will search something and find certain word in this request ,if exists page loading will be stopped (Search will be Cancelled) ?

UPDATE.

manifest.json:

  "background": {
    "scripts": ["background.js"]
  }
  "permissions": [
    "tabs",
    "webRequest",
    "webNavigation",
    "management",
    "http://*/*",
    "https://*/*",
    "*://*.google.com/",
    "webRequestBlocking",
    "<all_urls>"
  ]
}

background.js:

chrome.webRequest.onBeforeRequest.addListener(
  function(details) {
    return {cancel: details.url.indexOf("://salom/") != -1};
  },
  { urls: ["<all_urls>"] },
  ["blocking"]
);
wOxxOm
  • 65,848
  • 11
  • 132
  • 136
A'zam Mamatmurodov
  • 370
  • 1
  • 5
  • 14
  • You must post the code you've tried to make it easier helping you. – wOxxOm Nov 20 '15 at 14:40
  • You should have edited the question or you could give a link to something like pastie.org. The problem in your code is the nonsensical usage of `indexOf`. It should be for example `indexOf("salom")` or `search(/\bsalom\b/i)` (actually this will require a lot of thought and testing). Also make sure you know how to use the documentation or google the syntax and meaning of the javascript functions. – wOxxOm Nov 20 '15 at 15:15

1 Answers1

-1

"background": { "scripts": ["background.js"] } "permissions": [ "tabs", "webRequest", "webNavigation", "management", "http://*/*", "https://*/*", "*://*.google.com/", "webRequestBlocking", "<all_urls>" ] } it was manifest json and background.js is

chrome.webRequest.onBeforeRequest.addListener(
  function(details) {
    return {cancel: details.url.indexOf("://salom/") != -1};
  },
  { urls: ["<all_urls>"] },
  ["blocking"]
);
A'zam Mamatmurodov
  • 370
  • 1
  • 5
  • 14