-
Notifications
You must be signed in to change notification settings - Fork 1
/
yamemex.html
61 lines (56 loc) · 1.87 KB
/
yamemex.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script src="db.js"></script>
<script>
chrome.browserAction.onClicked.addListener(function(tab) {
if (tab.url === 'chrome://newtab/') {
chrome.tabs.create({url: chrome.extension.getURL('blog.html')});
} else {
chrome.tabs.sendRequest(tab.id, {openAnnotationWindow: 'please'});
}
});
function getAnnotation(url, callback) {
sql('select * from annotations where url = ?', [url], function(t, results) {
if (results.rows.length === 0) {
callback(null);
} else {
callback(results.rows.item(0));
}
});
}
function setAnnotation(request) {
sql( 'replace into annotations ' +
' (timestamp, url, annotation, title, public) ' +
'values ' +
' (datetime(), ?, ? , ? , ? ) '
, [ request.updateAnnotationsFor
, request.annotations
, request.title
, request['public']
]
);
}
var annotations = {
'http://code.google.com/chrome/extensions/browserAction.html':
'These are the annotations for browserAction.html!'
};
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
if (request.updateAnnotationsFor === undefined) return;
setAnnotation(request);
}
);
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
if (request.getAnnotationsFor === undefined) return;
getAnnotation(request.getAnnotationsFor, function(row) {
if (!row) {
sendResponse({'public': 1});
} else {
sendResponse({ annotation: row.annotation
, 'public': row.public
, title: row.title
});
}
});
}
);
</script>