에 액세스하고 싶습니다. 내 manfiest.json은이 위치입니다.Chrome 확장 프로그램의 로컬 저장소
{
"manifest_version": 2,
"name": "GTmetrix Analyzer Plugin",
"description": "This extension will analyze a page using GTmetrix",
"version": "2.1",
"options_page": "options.html",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"permissions": ["tabs", "storage"],
"content_scripts": [
{
"matches": ["http://ticketchest.geekschicagolabs.com/admin/orderHistory"],
"css": ["mystyles.css"],
"js": ["jqueryui-min.js", "content-script.js"]
}
]
}
내 popup.html이
<!doctype html>
<html>
<head>
<title>Ticket chest</title>
<script src="popup.js"></script>
</head>
<body>
<h1>Ticket chest extension</h1>
<a href="options.html">Settings</a>
<!-- <button id="checkPage">Check this page now!</button> -->
</body>
</html>
하고 background.js는
chrome.runtime.onMessage.addListener(function(response, sender, sendResponse){
localStorage['privateKeyy'] = response;
});
지금 나는 그것이 또한 수의 로컬 저장소에 저장됩니다 어떤 사용자가 텍스트 영역에 입력 할 것입니다 extenison의 로컬 저장소가있는 웹은 확장 로컬 저장소에 저장되지만 웹 페이지에는 저장되지 않습니다.
하고 (대신 확장의 배경 스크립트 코드를 (전용) 실행의) 콘텐츠 스크립트 코드를 이동 웹 페이지의 로컬 스토리지에 데이터를 저장하고자하는 경우 그 내용 스크립트 코드
window.onload = function() {
document.getElementById('save').onclick = function(){
var privateKey = document.getElementById("textarea").value;
chrome.storage.sync.set({'privateKey':privateKey}, function(){
//document.getElementById('privateKey').value = privateKey;
//chrome.browserAction.setBadgeBackgroundColor({color:[200, 0, 0, 100]});
//chrome.tabs.sendMessage(privateKey);
chrome.storage.local.set({'privateKeyy':privateKey});
localStorage.setItem("lastname", "Smith");
alert('save successfully');
});
//syncStorage["privateKey"] = privateKey;
}
document.getElementById('erase').onclick = function(){
chrome.storage.sync.remove('privateKey', function(){
alert('erase successfully');
});
}
document.getElementById('get').onclick = function(){
chrome.storage.sync.get('privateKey', function(data){
alert(data.privateKey);
console.log(data.privateKey);
});
}
}
PHP와 관련이 있습니까? – Farkie
https://developer.chrome.com/extensions/storage – Farkie
@Farkie 나는이 링크를 따라 간다. 잘못된 키가 웹 페이지의 로컬 저장소에 저장되지 않는다 ... – hu7sy