weibo.js
authorChris <chris@roojs.com>
Mon, 20 Jan 2014 10:55:52 +0000 (18:55 +0800)
committerChris <chris@roojs.com>
Mon, 20 Jan 2014 10:55:52 +0000 (18:55 +0800)
weibo.js

index 9facedf..67a8e90 100644 (file)
--- a/weibo.js
+++ b/weibo.js
@@ -1,7 +1,52 @@
-/* 
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
 
+(function run_weibo(u, p){
+    if(document.location.host=='weibo.com') {
+        // clear login dialog from weibo.
+        //check and hidden the login dialog and overlay .....
+        var els = document.querySelectorAll('div[node-type]');
+        var bbc = [];
+        for (i = 0; i < els.length; i++) {
+            if (els[i].hasAttribute('node-type')) {
+                if(els[i].getAttribute('node-type') == 'outer'){
+                    bbc.push(els[i]);
+                }
+            }
+        }
+        for (i = 0; i < bbc.length; i++) {// hide all the outer.....
+            bbc[i].style.display = 'none';
+        }
 
+        //try to login 
+        if(document.location.pathname == '/login.php'){
+
+            // fills in the user name and password 
+            var els = document.querySelectorAll('input[node-type]');
+
+            for (i = 0; i < els.length; i++) {
+                if (els[i].hasAttribute('node-type')) {
+                    if(els[i].getAttribute('node-type') == 'username'){
+                        els[i].value = u;
+                    }
+                    if(els[i].getAttribute('node-type') == 'password'){
+                        els[i].value = p;
+                    }
+                }
+            }
+
+
+            // simulating click event to login ....
+            var elss = document.querySelectorAll('a[node-type]');
+
+            for (i = 0; i < elss.length; i++) {
+                if (elss[i].hasAttribute('node-type')) {
+                    if(elss[i].getAttribute('node-type') == 'submitBtn'){
+                        elss[i].click();
+                    }
+                }
+            }
+
+
+        }
+
+    }
+})