Changeset 19029
- Timestamp:
- 09/09/08 02:46:02 (5 years ago)
- Location:
- lang/javascript/CvT
- Files:
-
- 2 modified
-
comment_via_twitter.user.js (modified) (7 diffs)
-
test.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/CvT/comment_via_twitter.user.js
r14591 r19029 3 3 // @namespace com.mesolabs 4 4 // @description Comment via Twitter 5 // @include * 5 // @include http://* 6 // @include https://* 7 // @include ftp://* 6 8 // ==/UserScript== 7 9 … … 11 13 var twitterId; 12 14 var cvtElement = document.getElementById("_cvt_twitterId"); 13 15 14 16 if (cvtElement && cvtElement.textContent) { 15 17 twitterId = cvtElement.textContent; … … 17 19 } else { 18 20 var href1 = document.location.href; 19 var href2 = href1.match(/\/$/) ? href1.replace(/\/ $/, "") : href1 + "/";21 var href2 = href1.match(/\/$/) ? href1.replace(/\/+$/, "") : href1 + "/"; 20 22 21 23 // tako3から取得 … … 29 31 load(foooUrl + href2); 30 32 } 31 33 32 34 function load(url) { 33 35 GM_xmlhttpRequest({ 34 36 method: "GET", 35 37 url: url, 36 onload: function(res) {37 if (!twitterId) {38 onload: function(res) { 39 if (!twitterId) { 38 40 eval(res.responseText); 39 if (twitterId) {41 if (twitterId) { 40 42 showForm(); 41 43 } … … 44 46 }); 45 47 } 46 48 47 49 function tako3(response) { 48 for (var i = 0 ; i < response.length; i++) {50 for (var i = 0, l = response.length, url; i < l; i++) { 49 51 url = response[i]; 50 if (url.match(/http:\/\/twitter.com\/.*/)) { 51 url = url.match(/\/$/) ? url.replace(/\/$/, "") : url; 52 tmp = url.replace(/http:\/\/twitter.com\//, ""); 53 if (tmp != "home") { 54 twitterId = tmp; 55 } 52 if (/https?:\/\/twitter\.com\/([^\/]+)/.test(url) && 53 RegExp.$1 != "home") { 54 twitterId = RegExp.$1; 56 55 } 57 56 } 58 57 } 59 58 60 59 function showForm(twitterId) { 61 60 var form = // 62 61 <form action="#" id="_cvt_form"> 63 Comment via Twitter: <input type="text" id="_cvt_text" />64 <input type="button" value="投稿" id="_cvt_submit" />62 Comment via Twitter: <input type="text" id="_cvt_text"/> 63 <input type="button" value="投稿" id="_cvt_submit"/> 65 64 </form>; 66 65 … … 101 100 function submit() { 102 101 var status = encodeURIComponent( 103 "@" + twitterId + " (" + document.location.href + ") " +102 "@" + twitterId + " <" + document.location.href + "> " + 104 103 document.getElementById("_cvt_text").value); 105 104 var url = "http://twitter.com/statuses/update.json"; … … 111 110 data: "status=" + status, 112 111 headers: { 113 "Content-Type": "application/x-www-form-urlencoded",112 "Content-Type": "application/x-www-form-urlencoded", 114 113 "X-Twitter-Client": "Comment via Twitter", 115 "X-Twitter-Client-Version": "0.1" 114 "X-Twitter-Client-Version": "0.1", 115 "User-Agent": "Comment-via-Twitter/0.1 (Greasemonkey)" 116 116 }, 117 117 onload: function(xhr) { -
lang/javascript/CvT/test.html
r14528 r19029 1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"> 3 3 <head> 4 4 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> … … 6 6 </head> 7 7 <body> 8 8 9 9 <div id="_cvt_twitterId" style="visibility: hidden;">meso</div> 10 10 </body>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)