Skip to content

Commit

Permalink
1.0.12 Load cloud save when install
Browse files Browse the repository at this point in the history
  • Loading branch information
annndruha committed Nov 6, 2023
1 parent 4b6faa1 commit 8c82252
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

chrome.runtime.onInstalled.addListener(() => {
console.log('Extension installed')
chrome.tabs.create({'url': 'chrome://newtab/'})
chrome.storage.local.clear()

function varDefined(v) {
return v !== 'undefined' && v !== 'null' && v !== null && v !== undefined && v !== ''
}

chrome.storage.sync.get(null, (json) => {
if (varDefined(json['rows'])) {
console.log('Load bookmarks from cloud...')
chrome.storage.local.clear(() => {
chrome.storage.local.set(json, () => {
console.log('Cloud bookmarks set to local storage.')
chrome.tabs.create({'url': 'chrome://newtab/'})
})
})
} else {
console.log('Cloud hasn\'t any data')
chrome.tabs.create({'url': 'chrome://newtab/'})
}
})
})
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Pulchra Bookmarks",
"description": "Pulchra Bookmarks extension",
"version": "1.0.11",
"version": "1.0.12",
"manifest_version": 3,
"minimum_chrome_version": "96",
"chrome_url_overrides": {
Expand Down

0 comments on commit 8c82252

Please sign in to comment.