chrome extensions & debug

chrome extensions & debug

debug background.js

740516-20181218094014499-1012769219.png

debug popup.js

740516-20181218094309635-315045160.png

debug content_script.js

740516-20181218094513487-1695290850.png

740516-20181218094708620-617549393.png

chrome.storage

chrome.storage.sync.get bug

740516-20181218110415272-1820986671.png


// array OK
chrome.storage.sync.get([
    "jira_str",
    "jira_obj"
], function(items) {
    console.log(`chrome.storage.sync.get OK!`);
    console.log(`get items =`, JSON.stringify(items, null, 4));
});

// object Error
chrome.storage.sync.get({
    jira_str,
    jira_obj,
}, function(items) {
    console.log(`chrome.storage.sync.get OK!`);
    console.log(`get items =`, JSON.stringify(items, null, 4));
});

// chrome.storage.sync.get({
//     "jira_str",
//     "jira_obj",
// }, function(items) {
//     console.log(`chrome.storage.sync.get OK!`);
//     console.log(`get items =`, JSON.stringify(items, null, 4));
// });

API

https://developer.chrome.com/extensions/storage

https://developer.chrome.com/extensions/storage#using-sync

To store user data for your extension, you can use either storage.sync, or storage.local


// storage.sync
chrome.storage.sync.set({key: value}, function() {
    console.log('Value is set to ' + value);
});

chrome.storage.sync.get(['key'], function(result) {
    console.log('Value currently is ' + result.key);
});
// storage.local:

chrome.storage.local.set({key: value}, function() {
    console.log('Value is set to ' + value);
});

chrome.storage.local.get(['key'], function(result) {
    console.log('Value currently is ' + result.key);
});

https://stackoverflow.com/questions/14531102/saving-and-retrieving-from-chrome-storage-sync

https://stackoverflow.com/questions/22636771/chrome-storage-sync-vs-chrome-storage-local

https://bugs.chromium.org/p/chromium/issues/detail?id=161771

localStorage API

https://developer.mozilla.org/en/DOM/Storage#localStorage


zip

bash shell zip

# admin pwd
$ sudo apt install zip

$ zip -r chrome-jira.2018.12.18.zip chrome-jira/*

740516-20181218113525999-1043662915.png

https://www.cnblogs.com/xgqfrms/p/9714161.html


official api docs

https://developer.chrome.com/extensions
https://developer.chrome.com/extensions/windows

https://developer.chrome.com/extensions/extension

https://developer.chrome.com/extensions/commands

https://developer.chrome.com/extensions/browserAction
https://developer.chrome.com/extensions/pageAction

https://developer.chrome.com/extensions/runtime
https://developer.chrome.com/extensions/runtime#property-lastError

https://developer.chrome.com/extensions/tabs

https://developer.chrome.com/extensions/system_storage
https://developer.chrome.com/extensions/system_memory
https://developer.chrome.com/extensions/system_cpu

https://developer.chrome.com/extensions/platformKeys

https://developer.chrome.com/extensions/omnibox

转载于:https://www.cnblogs.com/xgqfrms/p/10135273.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值