Yesterday, while making my daily post here, I realized one thing that my custom news poster has over Blogger: I can make custom tags. My news poster lets me put [URL]http://www.poonheads.com[/URL] and automatically makes it into a link. Yesterday, I had to write out the full HTML, which annoys me.
That got me thinking... I don't have any control over the server side of the app, so I can't add custom tags in there. But I *DO* have control over the client (or at least enough to make a difference). So I got to work with some javascript haxing.
I'm not too good with either javaScript OR regular expressions, but I make due. var pees = document.getElementsByTagName("p");
var RegExp = /\s(http[s]?:[/]+[\S]+)/g
for(var k = 0; k < pees.length; k++)
{
pees[k].innerHTML = pees[k].innerHTML.replace(RegExp, " $1");
}
The Blogger template gives me crap about malformed xml, so I crammed it into a .js and put it up on my server. It's at http://www.poonheads.com/replace.js . It's not 100%, but it gets the job done. Using the same principle (and a lot of wasted time making up regex's) I could probably hack up all kinds of stuff.
If I plan on doing a lot of code excerpts, I should probably hack up the <code> tag to display angle brackets and spaces. But I'm really lazy so I might not ever get around to it. Probably won't ever get around to it. But you never know.
So, do I get to call myself a javascript hacker yet? This counts, right?
Anyways, if you want more info on regex or javascript check out http://www.regular-expressions.info/ and http://www.w3schools.com/js/default.asp respectively.
Until next time,
~Ben
Wisdom Archive
- August 2008 (2)
- July 2008 (2)
- June 2008 (3)
- May 2008 (3)
- April 2008 (4)
- March 2008 (7)
- February 2008 (6)
- January 2008 (1)
- December 2007 (3)
- November 2007 (9)
- October 2007 (26)
- August 2007 (1)
- June 2007 (1)
- May 2007 (1)
- March 2007 (1)
- February 2007 (2)
- December 2006 (4)
- November 2006 (4)
- October 2006 (5)
- September 2006 (2)
- August 2006 (1)
Categories
- poonheads (22)
- music (17)
- comic (16)
- site news (12)
- coding (11)
- Classic Wisdom (10)
- video (10)
- I Love Music (9)
- javascript (9)
- photo (9)
- rant (8)
- tutorial (8)
- web design (8)
- hardware (7)
- hobby (7)
- mustaches (7)
- gear (6)
- horrifying (6)
- story time (6)
- earworm (5)
- food (5)
- art (4)
- software (4)
- Coding for Complete Noobs (3)
- movie (3)
- Captain Numbskull (2)
- Everyday Wisdom (2)
- beverage (2)
- knives (2)
- review (2)
- toys (1)
Tuesday, October 2, 2007
Blogger Hack
Labels:
coding,
javascript