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:
User logs in from testing-fb.local
Cookies are stored
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?