-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathenv.js
33 lines (31 loc) · 866 Bytes
/
env.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
(function() {
var listener = function(){};
sendMessage = function (data, callback) {
if(typeof chrome != 'undefined') {
return chrome.runtime.sendMessage(data, callback);
}
listener(data, null, callback);
}
onMessage = function (callback) {
if(typeof chrome != 'undefined') {
return chrome.runtime.onMessage.addListener(callback);
}
listener = callback;
}
shanbayplus_ajax = function (url, option) {
if (typeof chrome != 'undefined') {
return $.ajax(url, option);
}
option['url'] = url;
option['method'] = option['type'];
option['onerror'] = option['error'];
var success = option['success'];
option['onload'] = function(resp) {
success(resp.responseText);
}
delete option['type'];
delete option['error'];
delete option['success'];
return GM_xmlhttpRequest(option);
}
})();