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             
25             
26             // fills in the user name and password 
27             var els = document.querySelectorAll('input[node-type]');
28
29             for (i = 0; i < els.length; i++) {
30                 if (els[i].hasAttribute('node-type')) {
31                     if(els[i].getAttribute('node-type') == 'username'){
32                         els[i].value = u;
33                         console.log("set pass:" + u);
34                     }
35                     if(els[i].getAttribute('node-type') == 'password'){
36                         els[i].value = p;
37                         console.log("set pass:" + p);
38                     }
39                     
40                 }
41             }
42
43             // simulating click event to login ....
44             var elss = document.querySelectorAll('a[node-type]');
45             
46             for (i = 0; i < elss.length; i++) {
47                 if (elss[i].hasAttribute('node-type')) {
48                     if(elss[i].getAttribute('node-type') == 'submitBtn'){
49                         elss[i].click();
50                         console.log("press submit");
51                         break;
52                     }
53                 }
54             }
55         }
56         return;
57     }
58 }
59