weibo.js
[app.webkitpdf] / weibo.js
1
2 function run_weibo(u, p){
3     console.log("runing weibo");
4     if(document.location.host=='weibo.com') {
5         
6           
7         // clear login dialog from weibo.
8         //check and hidden the login dialog and overlay .....
9         var els = document.querySelectorAll('div[node-type]');
10         var bbc = [];
11         for (i = 0; i < els.length; i++) {
12             if (els[i].hasAttribute('node-type')) {
13                 if(els[i].getAttribute('node-type') == 'outer'){
14                     bbc.push(els[i]);
15                 }
16             }
17         }
18         for (i = 0; i < bbc.length; i++) {// hide all the outer.....
19             bbc[i].style.display = 'none';
20         }
21
22         //try to login 
23         if(document.location.pathname == '/login.php'){
24             console.log("runing weibo login");
25             // fills in the user name and password 
26             var els = document.querySelectorAll('input[node-type]');
27
28             for (i = 0; i < els.length; i++) {
29                 if (els[i].hasAttribute('node-type')) {
30                     if(els[i].getAttribute('node-type') == 'username'){
31                         els[i].value = u;
32                     }
33                     if(els[i].getAttribute('node-type') == 'password'){
34                         els[i].value = p;
35                     }
36                 }
37             }
38
39             //return;
40             // simulating click event to login ....
41             var elss = document.querySelectorAll('a[node-type]');
42
43             var event = document.createEvent("HTMLEvents");
44             event.eventType = "Click";
45             for (i = 0; i < elss.length; i++) {
46                 if (elss[i].hasAttribute('node-type')) {
47                     if(elss[i].getAttribute('node-type') == 'submitBtn'){
48                         elss[i].dispatchEvent(event);
49                        // elss[i].click();
50                         console.log("press submit");
51                         return;
52                     }
53                 }
54             }
55
56
57         }
58
59     }
60 }
61