-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
46 lines (34 loc) · 1.22 KB
/
Copy pathindex.html
File metadata and controls
46 lines (34 loc) · 1.22 KB
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
<!DOCTYPE HTML>
<html>
<head>
<title>old extension bar page</title>
<script type="text/javascript">
function jsonp(url, callback) {
var callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random());
window[callbackName] = function(data) {
delete window[callbackName];
callback(data);
};
var script = document.createElement('script');
script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'jsonp=' + callbackName;
document.body.appendChild(script);
}
//listen for button commands
safari.application.addEventListener("command", function(event) {
if(event.command === "make-dogeify") {
safari.application.activeBrowserWindow.activeTab.page.dispatchMessage(event.command);
}
}, false);
//listen for messages from injected script
safari.application.addEventListener("message", function(event){
if(event.name === 'get-images'){
jsonp('http://www.reddit.com/r/doge/.json', function(data) {
safari.application.activeBrowserWindow.activeTab.page.dispatchMessage("img-response",data);
});
}
},false);
</script>
</head>
<body>
</body>
</html>