I have done a small extension that change the default search engine and set the do not track function to on. The extension works, but it causes an issue on my website (and maybe others too).
On my website I have a settings page, to change some stuff, like the text color, the language. When I turn on the extension, the settings are not working any more. The buttons don't save my choices.
Edit: I noticed that the problem is coming from the "chrome_settings_overrides" part. If I take it off the buttons are working just fine again. Maybe something is blocking the POST request?
I have validate my website as a owner in the Google dev dashboard, but that don't change anything.
Here is the manifest.json :
{
"incognito": "spanning",
"name": "...",
"version": "1.0.5",
"manifest_version": 2,
"minimum_chrome_version": "23",
"icons": {
"16": "images/logo-16.png",
"32": "images/logo-32.png",
"48": "images/logo-48.png",
"128": "images/logo-128.png"
},
"chrome_settings_overrides": {
"search_provider": {
"encoding": "UTF-8",
"favicon_url": "http://www.mywebsite/favicon.ico",
"is_default": true,
"keyword": "...",
"name": "...",
"search_url": "http://www.mywebsite/search/index.php?a=web&q={searchTerms}"
}
},
"description": "...",
"default_locale": "fr",
"background": {
"scripts": [
"scripts/background.js"
]
},
"browser_action": {
"default_icon": {
"16": "images/logo-16.png",
"32": "images/logo-32.png",
"48": "images/logo-48.png"
},
"default_title": "mywebsite"
},
"options_page": "options.html",
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"permissions": [ "cookies", "webRequest", "webRequestBlocking", "activeTab" ]
}
And I use this kind of button for my settings page:
<form action="http://www.mywebsite.com/search/index.php?a=preferences" method="POST" class="form-horizontal">
<label class="radio">
<input type="radio" name="linkw" id="linkOffw" value="_top" {$linkOffw} />
<strong>Non</strong> - Ne pas ouvrir les résultats dans un nouvel onglet.
</label>
<label class="radio">
<input type="radio" name="linkw" id="linkOnw" value="_blank" {$linkOnw} />
<strong>Oui</strong> - Ouvrir les résultats dans un nouvel onglet.
</label>
<button type="submit" class="btn btn-info">Enregistrer mes préférences</button>
<a href="http://www.mywebsite.com" class="btn">Retour</a>
</form>
Do I need to set some permissions on my manifest or something like that?
Here is the background.js
chrome.webRequest.onBeforeSendHeaders.addListener(function(details) {
details.requestHeaders.push({name: "DNT", value: "1"});
return {requestHeaders: details.requestHeaders};
}, {urls: ["<all_urls>"]}, ["requestHeaders", "blocking"]);
function iconClicked() {
chrome.tabs.create({
'url': 'http://www.mywebsite.com'
});
}
chrome.browserAction.onClicked.addListener(iconClicked);