-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
localedit.js
executable file
·36 lines (32 loc) · 1.01 KB
/
localedit.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
28
29
30
31
32
33
34
35
36
let r = new URLSearchParams(window.location.search);
let docurl = r.get('url');
let item = null;
let error = false
let saveButton = document.getElementById('save')
chrome.bookmarks.search({url:docurl},res => {
if (res && res[0]) {
item = res[0]
let chunks = item.title.split('#__#')
title.value = chunks[0]
annotations.value = chunks[1]
saveButton.addEventListener('click',(evt) => {
evt.preventDefault()
evt.stopPropagation()
let newtitle = title.value.trim() + '#__#' + annotations.value.trim()
chrome.bookmarks.update(item.id,{title:newtitle}, res => {
window.close();
});
})
} else {
error = true
document.getElementById('error').textContent = "No bookmark for this page"
saveButton.textContent = 'close'
title.disabled = true
annotations.disabled = true
saveButton.addEventListener('click',(evt) => {
evt.preventDefault()
evt.stopPropagation()
window.close();
})
}
})