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                     }
34                     if(els[i].getAttribute('node-type') == 'password'){
35                         els[i].value = p;
36             
37                     }
38                 }
39             }
40
41             // simulating click event to login ....
42             var elss = document.querySelectorAll('a[node-type]');
43             
44             for (i = 0; i < elss.length; i++) {
45                 if (elss[i].hasAttribute('node-type')) {
46                     if(elss[i].getAttribute('node-type') == 'submitBtn'){
47                         elss[i].click();
48                         console.log("press submit");
49                         break;
50                     }
51                 }
52             }
53         }
54         return;
55     }
56 }
57