-
Notifications
You must be signed in to change notification settings - Fork 6
/
extension.js
99 lines (87 loc) · 2.52 KB
/
extension.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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var extension={
dir : '',
ver: function(fir,sec)
{
if (!sec) {sec=extension.manifest.version;};
if (!fir) {fir=extension.manifest.version;};
fir=fir.split('.');
sec=sec.split('.');
for(var i=0;i<fir.length;i++)
{
try{
fir[i]=parseInt(fir[i],10)
sec[i]=parseInt(sec[i],10)
}
catch(e){}
if (fir[i]>sec[i] || !sec[i])
return {left:true,right:false,equal:false,string:'left'};
if (fir[i]<sec[i])
return {left:false,right:true,equal:false,string:'right'};
}
if (!fir[i] && sec[i]) return {left:false,right:true,equal:false,string:'right'};
return ({left:false,right:false,equal:true,string:'equal'});
},
manifest : '',
version : 0,
online:true,
load : function ()
{
try{extension.dir=chrome.i18n.getMessage('dir');} catch (e) {extension.dir='ltr';extension.online=false}
if (extension.online)
{
extension.manifest=JSON.parse( jQuery.ajax( {url:'manifest.json',async:false }).responseText);
extension.version=extension.manifest.version;
jQuery(function(){
jQuery('.msg').each(function () {jQuery(this).html(chrome.i18n.getMessage(jQuery(this).attr('tag'))); });
jQuery('.ver').each(function () {jQuery(this).html(extension.manifest.version); });
jQuery(document.body).attr('dir', extension.dir) ;
jQuery('a.pophref').on('click',document.body,function () {window.open(this.href,'_new')})
});
}
}
}
if (navigator.appVersion.indexOf("Win")!=-1) extension.windows=true;
if (navigator.appVersion.indexOf("Mac")!=-1) extension.mac=true;
if (navigator.appVersion.indexOf("X11")!=-1) extension.x11=true;
if (navigator.appVersion.indexOf("Linux")!=-1) extension.linux=true;
local=false;
function testi18(){
extension.online=false;
chrome.i18n={
getMessage:function(ina){
return 'm(' + ina + ')';
}
}
chrome.permissions={
contains:function () {return true}
}
}
function lj_get(namespace,key,def){
var temp;
if(!namespace) {console.log('required parameters namespace');return}
if(!key) {console.log('required parameter key');return}
temp=localStorage[namespace] || '{}'
try{
temp=JSON.parse(temp)
}
catch(e){
temp={}
}
return temp[key] ==undefined ? def : temp[key]
}
function lj_set(namespace,key,value){
var temp;
if(!namespace) {console.log('required parameters namespace');return}
if(!key) {console.log('required parameter key');return}
temp=localStorage[namespace] || '{}'
try{
temp=JSON.parse(temp)
}
catch(e){
temp={}
}
temp[key]=value
localStorage[namespace]=JSON.stringify(temp)
}
if(!chrome.i18n) testi18()
extension.load();