Skip to content

Instantly share code, notes, and snippets.

@eliashussary
Last active February 26, 2024 18:52
Show Gist options
  • Save eliashussary/dfe8d0332561ee25b2b0614331f2df0e to your computer and use it in GitHub Desktop.
Save eliashussary/dfe8d0332561ee25b2b0614331f2df0e to your computer and use it in GitHub Desktop.
chrome webrequest onBeforeRequest example
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Simple extension to replace lolcat images from
// http://icanhascheezburger.com/ with loldog images instead.
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
console.log("Cat intercepted: " + info.url);
// Redirect the lolcal request to a random loldog URL.
var i = Math.round(Math.random() * loldogs.length);
return {redirectUrl: loldogs[i]};
},
// filters
{
urls: [
"https://i.chzbgr.com/*"
],
types: ["image"]
},
// extraInfoSpec
["blocking"]
);
@hoseindig
Copy link

hey
how can i get header request before send
pls simple exm if u can
tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment