-
Notifications
You must be signed in to change notification settings - Fork 3
/
statusBoxInject.js
34 lines (30 loc) · 1.19 KB
/
statusBoxInject.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
// Inject into IFRAME
$(document).ready(function(){
if ($("#sbWrapper").length > 0) {
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.messageType == "statusBox.collapse") {
$("#sbMore").hide();
$("#sbContent").hide();
LikeFM.resizeWindow();
}
sendResponse({}); // snub them.
});
var LikeFM = {
// After an action that might change the UI box size, call this
resizeWindow: function() {
chrome.extension.sendRequest({messageType: "statusBox.resize", data: {width:$("#sbWrapper").width()+10, height:Math.max($("#sbWrapper").height(),$(".ui-menu").height()+10)+30}}, function(response) {
});
}
};
// Refit window on first load
LikeFM.resizeWindow();
$("a").click(function(){
LikeFM.resizeWindow();
});
// Comm link with injected script
document.getElementById('LikeFMComm').addEventListener('resizeEvent', function() {
// Send message to background process
LikeFM.resizeWindow();
});
}
});