I wrote this a while ago, recently ported it to run on GitHub Pages: http://mustpax.github.com/Truth-Table-Generator/
I'm Mustafa Paksoy and I write code for a living. I post assorted items of interest here. You can contact me via email.
I also take pictures, dabble in Twitter and occasionally put projects on GitHub.
Just today I was thinking about how annoying it is that Facebook redirects all outgoing links to an internal page. They do this to mitigate the spread of clickjacking worms and whatnot but I like to think I’m smart enough to not click a post titled “I can’t believe she isnt werring a bra LOL WORM!!” So I figured I’d write a quick greasmonkey script to switch the links back to their pristine form. Well, I didn’t exactly get around to writing the script but I discovered something nifty instead.
Take the following innocuous link to a humorous imgur image a friend posted on my wall:
<a href="http://i.imgur.com/7XSdO.jpg" target="_blank" rel="nofollow"
onmousedown="UntrustedLink.bootstrap($(this), "SNIP", event, bagof(null));">
http://i.imgur.com/7XSdO.jpg
</a>
The link target (href) is not rewritten on the server so the click must be getting intercepted via JavaScript. But you can’t preventDefault for a click via onmousedown, you have to catch the onclick event instead. Here’s what UntrustedLink looks like once beautified:
function UntrustedLink(a, d, b, c) {
this.dom = a;
this.url = a.href;
this.hash = d;
this.func_get_params = c ||
function () {
return {};
};
Event.listen(this.dom, 'click', this.onclick.bind(this));
Event.listen(this.dom, 'mousedown', this.onmousedown.bind(this));
Event.listen(this.dom, 'mouseup', this.onmouseup.bind(this));
Event.listen(this.dom, 'mouseout', this.onmouseout.bind(this));
this.onmousedown($E(b));
}
Facebook is adding onclick handlers to links right before the click happens. No wasting time with pesky onload initializations, links are self-initializing! Pretty neat.
-
-
-
Using Dropbox as a Git repository
So last month I wrote a bit about setting up your own personal Git repositories on a Linux box, and how to use...
-
Me: “Alright, I want you to go ahead and drag that file to your desktop.”
Client: “Pff. I don’t have a desktop, I have a laptop!” -
“If a worker labors under the threat of force or of need, or a student produces on demand, we may admire what they do, but despise what they are.”
-
How To Tell if Different Kinds Of Fruit Are Ripe
It seems like everyone these days has some kind of quick tip for gauging the ripeness of fruit.
Still, billions of shoppers every day find themselves in the produce aisle, ears pressed to cassava melons, grinning like idiots.
-
Client: “I need your agency to develop a robust morale-boosting program for the top 100 ‘leaders’ in our region during our annual team building...
-
EZ-Laminator450 Users Manual: Frequently Asked Questions
FAQ
Is this the same type of laminator they have at high schools?
Yes! Your I.D. card...