// ==UserScript== // @name Hateda Poster // @namespace http://web.zgo.jp/ // @description はてなダイアリーポスト機構 // @include * // ==/UserScript== var v = GM_getValue("W-SSE"); function Requester(user, pass){ this.user = user; this.pass = pass; } Requester.prototype = { post : function (tag, title, comment, callback){ var postURI = "http://d.hatena.ne.jp/"+this.user+"/atom/blog"; tag = (tag.length == 0) ? "" : "["+tag.join("][")+"]"; comment = (comment.length == 0) ? "" : comment; GM_xmlhttpRequest({ method : "POST", url : postURI, data : this.template(tag, title, comment), onload : callback, headers : { "Content-Type" : "application/atom+xml; charset=UTF-8", "Accept" : "application/x.atom+xml, application/xml, text/xml, */*", "X-WSSE" : this.wsseHeader(this.user, this.pass) } }) }, template : function (tag, title, comment){ var repuest = {tag}{title} {comment} ; //GM_log(repuest); return repuest.toString(); }, include : function (_win){ _win.eval(v); this.wsseHeader = _win.wsseHeader; return this; } } if(typeof v == "undefined"){ GM_xmlhttpRequest({ method : "GET", url : "http://reader.livedoor.com/js/wsse.js", onload : function (response){ GM_setValue("W-SSE", response.responseText); } }) } else { window.Hateda = Requester; } //.user.js