-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
27 lines (21 loc) · 903 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
console.log('remoteStorage', remoteStorage);
// close auth dialog, once it's finished.
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
var authTabId = localStorage.getItem('auth-tab-id');
if(authTabId && (tabId == authTabId)) {
// only close, if URL also ends on #. That signals, that the access_token
// has been recovered from fragment.
if(changeInfo.url && changeInfo.url.match(/^chrome\-extension:\/\/.*#$/)) {
chrome.tabs.remove(Number(authTabId));
localStorage.removeItem('auth-tab-id')
}
}
});
window.onload = function() {
var div = document.createElement('div');
div.setAttribute('id', 'remotestorage-connect');
document.body.appendChild(div);
remoteStorage.defineModule('bookmarks', function() { return { exports: {} } });
remoteStorage.claimAccess({'bookmarks':'rw'});
remoteStorage.displayWidget('remotestorage-connect');
}