Anonymous (owner)

Revisions

  • d0e3f9 Sat Dec 13 05:30:27 -0800 2008
  • 353709 Sat Dec 13 05:01:41 -0800 2008
gist: 35464 Download_button fork
public
Description:
undefined
Public Clone URL: git://gist.github.com/35464.git
Text only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==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 = <entry xmlns="http://purl.org/atom/ns#">
         <title>{tag}{title}</title>
         <content type="text/plain">
{comment}
</content>
</entry>;
//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