特定のゲームがアップデートを受信したときにユーザーに通知する拡張機能を作成しています。データは、MySQLデータベースから受信されます。HTTPSでAjaxコールがブロックされた - Chrome拡張機能
ローカルホストサーバー(テスト目的)でPHPスクリプトによって提供されるjsonデータを受信するためにajax呼び出しを行いました。
これは、HTTP Webサイトで正常に動作します。しかし、スクリプトはHTTPSウェブサイトによってブロックされます。
メッセージグーグルからこのトラブルシューティングのページにつながる、「このページには、認証されていないソースからのスクリプトをロードしようとしている」されています Link
任意の提案ですか?
マニフェスト:
{
"manifest_version": 2,
"name": "Extension",
"version": "1.0",
"icons": {
"128": "icon128.png",
"48": "icon48.png",
"16": "icon16.png"
},
"page_action": {
"default_icon": "icon16.png",
"default_popup": "popup.html"
},
"background":{
"scripts" : ["eventPage.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js", "jquery-3.2.0.min.js"],
"css": ["content.css"],
"run_at": "document_start",
"match_about_blank": true
}
],
"permissions": [
"notifications", "http://localhost/*", "tabs"
]}
eventPage.js
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {todo: "displayNews"});
});
});
content.jsが
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
if (request.todo == "displayNews"){
$.ajax({
url: 'http://localhost/database/connect.php',
type:'POST',
dataType: 'json',
success: function(output_string){
alert(output_string[1].url);
},
error: function (xhr, ajaxOptions, thrownError){
alert(xhr.statusText);
alert(thrownError);
}
});
//Some other code is executed here
}});
[このサイトが役立つかもしれません](https://developer.chrome.com/extensions/xhr) –
HTTPSサイトでHTTP APIへのAJAX呼び出しを行うことはできません。ローカルホスト上にHTTPSサーバーを実装する必要があります。 – Barmar