-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutil.js
More file actions
73 lines (71 loc) · 1.89 KB
/
util.js
File metadata and controls
73 lines (71 loc) · 1.89 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
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
var whvutil = (function(){
function getContext(){
return {
loginname: 'ccschen',
loginpwd: 'Passw0rd',
country: 214,
familyname: 'Chen',
givenname: 'Chunsen',
gender: 'F',
birthday: '1984/12/21',
streetname: 'abc',
city: 'New York',
email: 'zhuxw1984@163.com',
passportnumber: '12345678',
passportexpire: '2020/1/1',
idcarddate: '2014/1/1',
traveldate: '2015/7/1',
payername: 'Zhang San',
cardtype: 'master',
creditcardnumber: '12345678',
creditcardcode: '789',
creditcardexpire: '2020/1/1',
cardholder: 'Zhang San'
};
}
function getEmptyContext(){
var context = getContext();
for(var name in context){
context[name] = '';
}
return context;
}
function step(id, callback){
chrome.storage.local.set({
whvstep: id
}, callback);
}
return {
fireEvent: function(element, event){
var evt;
if(document.createEventObject){
// dispatch for IE
evt = document.createEventObject();
return element.fireEvent('on' + event, evt);
}else{
// dispatch for firefox + others
evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);
}
},
autoLoad: function(callback){
var context = getEmptyContext();
context.enableWhv = false;
chrome.storage.sync.get(context, function(args){
if(args.enableWhv && callback(args)){
var nextButton = document.getElementById("ctl00_ContentPlaceHolder1_wizardPageFooter_wizardPageNavigator_nextImageButton");
var submitButton = document.getElementById("ctl00_ContentPlaceHolder1_wizardPageHeader_nav_submitImageButton");
if(submitButton){
whvutil.fireEvent(submitButton, 'click');
}else if(nextButton){
whvutil.fireEvent(nextButton, 'click');
}
}
});
},
getContext: getContext,
getEmptyContext: getEmptyContext,
step: step
};
})();