Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 2 of 2

This is a discussion on chrome.webRequest.onBeforeRequest.removeListener within the Chrome Plugins section, part of the Google Chrome category: I'm writing an extension. In background.html I have this: Code: chrome.webRequest.onBeforeRequest.addListener(function(object_details){console.log('event listened')},{types: ['xmlhttprequest'], urls: ['*://*/*']}, ["blocking"]) So, when XMLHttpRequests occur ...


  1. #1
    plavozont is offline Junior Member
    Join Date
    May 2012
    Posts
    5

    Default chrome.webRequest.onBeforeRequest.removeListener

    I'm writing an extension. In background.html I have this:
    Code:
    chrome.webRequest.onBeforeRequest.addListener(function(object_details){console.log('event listened')},{types: ['xmlhttprequest'], urls: ['*://*/*']},
    ["blocking"])
    So, when XMLHttpRequests occur I can see logs in background.html console.

    Then (in the console or background.html itself, doesn't matter) I write this:
    Code:
    chrome.webRequest.onBeforeRequest.removeListener(null)
    I expect that the logs(saying 'event listened') will stop. But they don't! I tried to removeListener in many ways but nothing works. Please Help!!!

  2. #2
    plavozont is offline Junior Member
    Join Date
    May 2012
    Posts
    5

    Default

    Eureka!

    Code:
    var onBeforeRequest_callback=function(object_details){console.log('event listened')
    chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest_callback,{types: ['xmlhttprequest'], urls: ['*://*/*']},["blocking"])
    Code:
    chrome.webRequest.onBeforeRequest.removeListener(onBeforeRequest_callback)


Similar Threads

  1. WebRequest api troubles with parameters
    By JacKeown in forum Chrome Plugins
    Replies: 0
    Last Post: 09-25-2011, 09:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •