I like it when a new programming challenge crosses my mind. This is something i've never done before and it was a fun, quick challenge.
It all started with a simple twitter post that said
So who's writing the scipt to automatically put
#squarespace into every tweet for the next 30 days?
Since I use blu as my twitter client of choice (for now), my mind went immediately to how to manipulate the post to the server. I pulled up fiddler, a web debugging proxy to view and minipulate request and response data.
I made a post via blu while fiddler was running and looked for the request data.

I then checked the raw post to see how it was posting it to the server - in this case it was a simple HTTP POST. NOTE: this example image is after my modification.

A little poking around and I found that you could manipulate the body and then send the manipulated version. Even programatically
I opened up my CustomRules.js by going to Rules -> Customize Rules and modified the OnbeforeRequest method and added:
// intercept blu twitter posts and append data.
if (oSession.HTTPMethodIs("POST") && (oSession.HostnameIs("twitter.com") || oSession.HostnameIs("www.twitter.com"))){
var oBody = System.Text.Encoding.UTF8.GetString(oSession.requestBodyBytes);
oBody = oBody.replace("&source", Uri.EscapeDataString( " #squarespace") + "&source");
oSession.utilSetRequestBody(oBody);
}
Basically, i'm being really cheap here and doing a simple replace.
Line 4: Capturing the body
Line 6: Replacing &source (which is consistant) with a URI Properly Escaped string containing " #squarespace" and then the original &source parameter.
Line 8: Replacing the original body with the manipulated body.
Please Note, I know I am not checking the length of the string to make sure i'm within 140 characters; however, I don't care to use this, I just wanted to know if I could do it. This could easily be extended to check the length and only append if there is room. Let me know what you think via twitter or the comments below - or post any enhancements you have to this little snippet!
General
for fun, javascript, fiddler, twitter, blu