Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:31:52+00:00 2026-06-15T18:31:52+00:00

I have wrote a plugin for facebook that sends data to testing-fb.local . The

  • 0

I have wrote a plugin for facebook that sends data to testing-fb.local. The request goes through if the user is logged in.

Here is the workflow:

  1. User logs in from testing-fb.local
  2. Cookies are stored
  3. When $.ajax() are fired from the Chrome extension
    • Chrome extension listen with chrome.webRequest.onBeforeSendHeaders
    • Chrome extension checks for cookies from chrome.cookies.get
    • Chrome changes the Set-Cookies header to be sent

And the request goes through.

I wrote this part of code that shoud be this:

function getCookies (callback) {
  chrome.cookies.get({url:"https://testing-fb.local", name: "connect.sid"}, function(a){
    return callback(a)
  })
}

chrome.webRequest.onBeforeSendHeaders.addListener(
  function(details) {
    getCookies(function(a){

// Here something happens

    })
  },
  {urls: ["https://testing-fb.local/*"]},
  ['blocking']);

Here is my manifest.json:

{
  "name": "test-fb",
  "version": "1.0",
  "manifest_version": 1,
  "description": "testing",
  "permissions": [
    "cookies",
    "webRequest",
    "tabs",
    "http://*/*",
    "https://*/*"
  ],    
  "background": {
    "scripts": ["background.js"]
  },
  "content_scripts": [
        {
          "matches": ["http://*.facebook.com/*", "https://*.facebook.com/*"],
          "exclude_matches" : [
            "*://*.facebook.com/ajax/*",
            "*://*.channel.facebook.tld/*",
            "*://*.facebook.tld/pagelet/generic.php/pagelet/home/morestories.php*",
            "*://*.facebook.tld/ai.php*"
          ],
          "js": ["jquery-1.8.3.min.js", "allthefunctions.js"]
        }
      ]
}

In allthefunction.js I have the $.ajax calls, and in background.js is where I put the code above which however looks not to run..

In summary, I have not clear:

  • What I should write in Here something happens
  • If this strategy is going to work
  • Where should I put this code?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:31:53+00:00Added an answer on June 15, 2026 at 6:31 pm

    Chrome changes the Set-Cookies header to be sent, i believe you want to send a Custom Cookie header for an HTTP request, because Set-Cookie header is sent by the server in response to an HTTP request, which is used to create a cookie on the user’s system.

    Please note all Cookie API() methods are asynchronous, ensure your call back drives your functionality;

    I tried to replicate your workflow with this sample demonstration

    Demonstration

    Background page looks for all requests to http://www.w3schools.com/html/default.asp and modifies cookie details

    background.js

    // Adding Event Listener for Changing Cookie Details in Header
    chrome.webRequest.onBeforeSendHeaders.addListener(function (details) {
    
        // Look for header details here
        detail = "requestHeaders";
        headers = details[detail];
    
        // Iterate through all headers information
        for (header in headers) {
    
            // Stop at Cookie Information
            if (headers[header].name == "Cookie") {
    
                // Do your desired functionality either modifying/delet cookies etc
    
                //chrome.cookies.get({url:"<your url>", name: "<your parameter>"}, function(Cookies){
                //console.log("Cookies  "+Cookies);
                return {
                    requestHeaders: details.requestHeaders
                };
                //});
    
    
            }
        }
    
    },
    //Sample URL used
    {
        urls: ["http://www.w3schools.com/html/default.asp"]
    },
    
    // Block Web Request and request for header information
    
    ['blocking', "requestHeaders"]);
    

    allfunctions.js

    Simple AJAX Call to an asp page

     //Do an AJAX Call
     function ajaxCall() {
         $.post("http://www.w3schools.com/html/default.asp", function (data) {
             console.log("POST Completed " + data);
         });
     }
     ajaxCall();
    

    manifest.json

    Ensured manifest has all permissions

    {
      "name": "test-fb",
      "version": "1.0",
      "manifest_version": 2,
      "description": "testing",
      "permissions": [
        "cookies",
        "webRequest",
        "tabs",
        "<all_urls>",
        "webRequestBlocking" 
      ],    
      "background": {
        "scripts": ["background.js"]
      },
      "content_scripts": [
            {
              "matches": ["<all_urls>"],
              "js": ["jquery.js", "allthefunctions.js"]
            }
          ]
    }
    

    With this i was able to track request headers for AJAX Call and modify cookie information, let me know if you need more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Grails and I have a local-plugin (that I wrote) that I'm using
I have found a great plugin that sets Facebook comments on an article where
I wrote a Resharper plugin that seems to only work when users have the
I have Dynamics CRM 4.0 installed and wrote a plugin, registered it, and setup
I have wrote a script that was run from a spreadsheet. I had One
I have wrote an application that syncs two folders together. The problem with the
i have wrote a script to produce an array of data but now want
I am using jQuery Validation Plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) I have wrote following rule jQuery.validator.addMethod(valueNotEquals, function(value,
I wrote a plugin in Firebreath, and I have a msi written. I want
I have a shortcode inside a plugin I wrote. The shortcode always prints on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.