Index: /lang/javascript/userscripts/tubuyakix.user.js
===================================================================
--- /lang/javascript/userscripts/tubuyakix.user.js (revision 19663)
+++ /lang/javascript/userscripts/tubuyakix.user.js (revision 19663)
@@ -0,0 +1,399 @@
+// ==UserScript==
+// @name           tubuyakix
+// @namespace      http://www.sakito.com/
+// @description    Twitter and Wassr and nowa and others poster
+// @include        *
+// ==/UserScript==
+//
+// ***** BEGIN LICENSE BLOCK *****
+// Licensed under Version: GPL v3
+// Full Terms at http://www.gnu.org/copyleft/gpl.html
+// ***** END LICENSE BLOCK *****
+//
+// author: sakito
+//
+// this script based on
+// tiwt.user.js(http://jugyo.org/blog/2695)
+// original author: jugyo http://jugyo.org/blog/
+//
+// TODO:Jaiku, mogo2, haru.fm, himatch, Timelog, Weime, Cotobaco, Feecle
+//
+
+(function() {
+
+  var URL = "http://sakitodraftdoc.googlepages.com/tubuyakix.user.js.page";
+  var VERSION = "20080712";
+
+  if (self.location.href != top.location.href) {
+    return;
+  }
+  if (window != window.parent) {
+    return;
+  }
+
+  function init() {
+    init_tubuyakix_content();
+    init_tubuyakix_poster();
+    init_tubuyakix_menu();
+  }
+
+  function init_tubuyakix_content() {
+    var element = c("div", "tubuyakix_content");
+    with (element) {
+      with (style) {
+        zIndex = 1;
+        backgroundColor = "#00CC00";
+        position = "fixed";
+        top = "60px";
+        right = "0px";
+        overflow = "auto";
+        MozOpacity = 0.80;
+        minHeight = "16px";
+        minWidth = "16px";
+        padding = "2px";
+      }
+      addEventListener("mouseover", show_tubuyakix, false);
+      addEventListener("mouseout", hide_tubuyakix, false);
+    }
+    a(document.body, element);
+  }
+
+  function init_tubuyakix_poster() {
+    var element = c("div", "tubuyakix_poster");
+    with (element) {
+      with (style) {
+        padding = "2px";
+        display = "none";
+        textAlign = "right";
+      }
+    }
+
+    // FIXME
+    arguments.length > 0 ? tubuyakix_configarea(element):
+    load("accountsinfo") ? tubuyakix_postarea(element):
+                           tubuyakix_configarea(element);
+
+    var version = c("div","tubuyakix_version");
+    with(version) {
+      innerHTML = '<a href="' + URL + '">tubuyakix</a> ver ' + VERSION;
+      with(style) {
+        float = "left";
+      }
+    }
+    a(element, version);
+
+    a(e("tubuyakix_content"), element);
+  }
+
+  function init_tubuyakix_menu() {
+    GM_registerMenuCommand("tubuyakix - config", configmenu);
+  }
+
+  function tubuyakix_configarea(element) {
+
+    var infoelement = c("div","tubuyakix_infoarea");
+    with(infoelement) {
+      with(style) {
+        textAlign = "right";
+      }
+    }
+    a(element, infoelement);
+
+    tubuyakix_createinput(infoelement, "twitter");
+    tubuyakix_createinput(infoelement, "wassr");
+    tubuyakix_createinput(infoelement, "nowa");
+
+    var button = c("button", "tubuyakix_button");
+    with (button) {
+      innerHTML = "Save";
+      with (style) {
+        backgroundColor = "silver";
+        border = "solid 1px gray";
+      }
+      addEventListener("click", config, false);
+    }
+    a(element, button);
+
+  }
+
+  function tubuyakix_createinput(element, service) {
+
+    var infolabel = c("div","tubuyakix_" + service + "info");
+    with(infolabel) {
+      with(style) {
+        fontWeight = "bold";
+        textAlign = "right";
+        float = "left";
+      }
+    }
+    a(element, infolabel);
+
+    var infolabeluser = c("span","tubuyakix_" + service + "username" + "label");
+    with(infolabeluser) {
+      innerHTML = service + ' ' + "username";
+      with(style) {
+        fontWeight = "bold";
+        float = "left";
+      }
+    }
+    a(infolabel, infolabeluser);
+
+    var infoinputuser = c("input","tubuyakix_" + service + "username");
+    with(infoinputuser) {
+      with (style) {
+        value = "";
+        width = "100px";
+        height = "15px";
+        border = "solid 1px gray";
+        borderBottomColor = "silver";
+        borderRightColor = "silver";
+        float = "left";
+      }
+    }
+    a(infolabel, infoinputuser);
+
+    var infolabelpass = c("span","tubuyakix_" + service + "password" + "label");
+    with(infolabelpass) {
+      innerHTML = ' ' + "password";
+      with(style) {
+        fontWeight = "bold";
+        float = "left";
+      }
+    }
+    a(infolabel, infolabelpass);
+
+    var infoinputpass = c("input","tubuyakix_" + service + "password");
+    with(infoinputpass) {
+      with (style) {
+        value = "";
+        width = "100px";
+        height = "15px";
+        border = "solid 1px gray";
+        borderBottomColor = "silver";
+        borderRightColor = "silver";
+        float = "left";
+      }
+    }
+    a(infolabel, infoinputpass);
+
+  }
+
+  function configmenu() {
+    r(e("tubuyakix_content"), e("tubuyakix_poster"));
+    init_tubuyakix_poster("menu");
+    show_tubuyakix();
+  }
+
+  function config() {
+
+    var accountsinfo = {
+      "twitterusername" : v("tubuyakix_twitterusername"),
+      "twitterpassword" : v("tubuyakix_twitterpassword"),
+      "wassrusername" : v("tubuyakix_wassrusername"),
+      "wassrpassword" : v("tubuyakix_wassrpassword"),
+      "nowausername" : v("tubuyakix_nowausername"),
+      "nowapassword" : v("tubuyakix_nowapassword")
+    };
+
+    save("accountsinfo", accountsinfo);
+
+    e("tubuyakix_infoarea").style.display = "none";
+    e("tubuyakix_button").style.display = "none";
+
+    var configdonemsg = c("span","tubuyakix_configdone");
+    with(configdonemsg) {
+      innerHTML = "config done. Please Browser reload.";
+      with(style) {
+        fontWeight = "bold";
+      }
+    }
+    a(e("tubuyakix_content"), configdonemsg);
+  }
+
+  function tubuyakix_postarea(element) {
+    var textarea = c("textarea", "tubuyakix_textarea");
+    with (textarea) {
+      with (style) {
+        value = "";
+        display = "block";
+        width = "400px";
+        height = "60px";
+        marginBottom = "2px";
+        border = "solid 1px gray";
+        borderBottomColor = "silver";
+        borderRightColor = "silver";
+      }
+    }
+    a(element, textarea);
+
+    var img = c("img", "tubuyakix_indicator");
+    with (img) {
+      with (style) {
+        display = "none";
+        margin = "0 2px";
+      }
+      src = 'data:image/gif;base64,'+
+        'R0lGODlhEAAQAPQAAP///3d3d/r6+pSUlL29vXp6eouLi+jo6NDQ0IKCgrW1ta2trfDw8MfHx+Dg4J2dnaSkpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAAFUCAgjmRpnqUwFGwhKoRgqq2YFMaRGjWA8AbZiIBbjQQ8AmmFUJEQhQGJhaKOrCksgEla+KIkYvC6SJKQOISoNSYdeIk1ayA8ExTyeR3F749CACH5BAAKAAEALAAAAAAQABAAAAVoICCKR9KMaCoaxeCoqEAkRX3AwMHWxQIIjJSAZWgUEgzBwCBAEQpMwIDwY1FHgwJCtOW2UDWYIDyqNVVkUbYr6CK+o2eUMKgWrqKhj0FrEM8jQQALPFA3MAc8CQSAMA5ZBjgqDQmHIyEAIfkEAAoAAgAsAAAAABAAEAAABWAgII4j85Ao2hRIKgrEUBQJLaSHMe8zgQo6Q8sxS7RIhILhBkgumCTZsXkACBC+0cwF2GoLLoFXREDcDlkAojBICRaFLDCOQtQKjmsQSubtDFU/NXcDBHwkaw1cKQ8MiyEAIfkEAAoAAwAsAAAAABAAEAAABVIgII5kaZ6AIJQCMRTFQKiDQx4GrBfGa4uCnAEhQuRgPwCBtwK+kCNFgjh6QlFYgGO7baJ2CxIioSDpwqNggWCGDVVGphly3BkOpXDrKfNm/4AhACH5BAAKAAQALAAAAAAQABAAAAVgICCOZGmeqEAMRTEQwskYbV0Yx7kYSIzQhtgoBxCKBDQCIOcoLBimRiFhSABYU5gIgW01pLUBYkRItAYAqrlhYiwKjiWAcDMWY8QjsCf4DewiBzQ2N1AmKlgvgCiMjSQhACH5BAAKAAUALAAAAAAQABAAAAVfICCOZGmeqEgUxUAIpkA0AMKyxkEiSZEIsJqhYAg+boUFSTAkiBiNHks3sg1ILAfBiS10gyqCg0UaFBCkwy3RYKiIYMAC+RAxiQgYsJdAjw5DN2gILzEEZgVcKYuMJiEAOwAAAAAAAAAAAA==';
+    }
+    a(element, img);
+
+    var button = c("button", "tubuyakix_button");
+    with (button) {
+      innerHTML = "Post";
+      with (style) {
+        backgroundColor = "silver";
+        border = "solid 1px gray";
+      }
+      //addEventListener("click", post, false);
+      addEventListener("click", verifi, false);
+    }
+    a(element, button);
+
+  }
+
+  function verifi() {
+
+    var accountsinfo = load("accountsinfo");
+
+    var twitterInfo = {
+    "username" : accountsinfo.twitterusername,
+    "password" : accountsinfo.twitterpassword
+    };
+    if (twitterInfo.username != "" && twitterInfo.password != "") {
+      var twitterEndPoint   = [
+                               'https://',
+                               twitterInfo.username,
+                               ':',
+                               twitterInfo.password,
+                               '@twitter.com/statuses/update.json'
+                               ].join('');
+      post(twitterEndPoint);
+    }
+
+    var wassrInfo = {
+    "username" : accountsinfo.wassrusername,
+    "password" : accountsinfo.wassrpassword
+    };
+    if (wassrInfo.username != "" && wassrInfo.password != "") {
+      var wassrEndPoint   = [
+                             'http://',
+                             wassrInfo.username,
+                             ':',
+                             wassrInfo.password,
+                             '@api.wassr.jp/update.json?id=',
+                             wassrInfo.username
+                             ].join('');
+      post(wassrEndPoint);
+    }
+
+    var nowaInfo = {
+    "username" : accountsinfo.nowausername,
+    "password" : accountsinfo.nowapassword
+    };
+    if (nowaInfo.username != "" && nowaInfo.password != "") {
+      var nowaEndPoint   = [
+                            'https://',
+                            nowaInfo.username,
+                            ':',
+                            nowaInfo.password,
+                            '@api.nowa.jp/status_message/update.json'
+                            ].join('');
+      post(nowaEndPoint);
+    }
+
+  }
+
+  function post(endPoint) {
+    e("tubuyakix_button").style.display = "none";
+    e("tubuyakix_indicator").style.display = "inline";
+
+    GM_xmlhttpRequest({
+      method: 'POST',
+          url: endPoint,
+          data: 'status=' + encodeURIComponent(e("tubuyakix_textarea").value),
+          headers: {
+          'Content-Type' : 'application/x-www-form-urlencoded'
+            },
+          onload : function (req) {
+          e("tubuyakix_button").style.display = "inline";
+          e("tubuyakix_indicator").style.display = "none";
+          e("tubuyakix_textarea").value = "";
+          e("tubuyakix_textarea").focus();
+        },
+          });
+  }
+
+  function show_tubuyakix() {
+    d("tubuyakix_poster", "block");
+
+    e("tubuyakix_textarea")        ? e("tubuyakix_textarea").focus():
+    e("tubuyakix_twitterusername") ? e("tubuyakix_twitterusername").focus():
+                                     e("tubuyakix_button").focus();
+  }
+
+  function hide_tubuyakix() {
+    d("tubuyakix_poster", "none");
+  }
+
+  function init_style(style) {
+    with(style) {
+      fontSize = "12px";
+      textAlign = "left";
+      padding = 0;
+      margin = 0;
+      lineHeight = "15px";
+      color = "black";
+      backgroundColor = "none";
+      border = "none";
+    }
+  }
+
+  // GM utils
+  function log(value) {
+   GM_log(value);
+  }
+
+  function save(id, value) {
+    GM_setValue(id, value.toSource());
+  }
+
+  function load(id) {
+    return eval(GM_getValue(id, false)) || false;
+  }
+
+  // layout utils
+  function a(parent, child) {
+    parent.appendChild(child);
+  }
+
+  function r(parent, child) {
+    parent.removeChild(child);
+  }
+
+  function c(tag_name, element_id) {
+    element = document.createElement(tag_name);
+    with (element) {
+      id = element_id;
+      init_style(style);
+    }
+    return element;
+  }
+
+  function u(id, text) {
+    e(id).innerHTML = text;
+  }
+
+  function e(id) {
+    return document.getElementById(id);
+  }
+
+  function v(id) {
+    return document.getElementById(id).value;
+  }
+
+  function d(id, value) {
+    e(id).style.display = value;
+  }
+
+  init();
+ })();
