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         document.location='http://www.google.com';
7         return;
8         
9         // clear login dialog from weibo.
10         //check and hidden the login dialog and overlay .....
11         var els = document.querySelectorAll('div[node-type]');
12         var bbc = [];
13         for (i = 0; i < els.length; i++) {
14             if (els[i].hasAttribute('node-type')) {
15                 if(els[i].getAttribute('node-type') == 'outer'){
16                     bbc.push(els[i]);
17                 }
18             }
19         }
20         for (i = 0; i < bbc.length; i++) {// hide all the outer.....
21             bbc[i].style.display = 'none';
22         }
23
24         //try to login 
25         if(document.location.pathname == '/login.php'){
26             console.log("runing weibo login");
27             // fills in the user name and password 
28             var els = document.querySelectorAll('input[node-type]');
29
30             for (i = 0; i < els.length; i++) {
31                 if (els[i].hasAttribute('node-type')) {
32                     if(els[i].getAttribute('node-type') == 'username'){
33                         els[i].value = u;
34                     }
35                     if(els[i].getAttribute('node-type') == 'password'){
36                         els[i].value = p;
37                     }
38                 }
39             }
40
41
42             // simulating click event to login ....
43             var elss = document.querySelectorAll('a[node-type]');
44
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].click();
49                         console.log("press submit");
50                         return;
51                     }
52                 }
53             }
54
55
56         }
57
58     }
59 }
60