Hey,
A couple of days back, I saw an paper on Context Aware Image Resizing by Dr. Ariel Shamir and Dr. Shai Avidan. The concept seemed interesting, and the demonstration video showed some example of how effective context aware image resizing can get. There were people asking for it as a feature in Photoshop.
I was wondering if this could be a useful in HTML pages. Thats how I sat down and started writing quick Javascript to see this magic for images in HTML page. The algorithm over all is simple; the only complexity lies in defining the energy function. This article explains the architecture of the JavaScript code and its functionality of the HTML image resizing code that I am writing. As soon as I give the final touches to the HTML code, I would put it out.
The JavaScript code is non-obtrusive, and requires HTML 5 Canvas element. It does nothing if HTML 5 is not supported. Consider an image is defined using a tag like <image src = "blah" class="autoresize" style = "height : 100; width : 100" >
A wrapper JavaScript class reads the HTML for all the image tags with the specific classname, and initializes them to a ImageResize class. As initialization, the image resize calculates the energy function (that can be customized), then the horizontal and vertical seams using dynamic programming as described in the paper. It then redraws the entire image for that particular dimension. The resize is also captured to enable dynamic image resizing, one of the "wow" factor of the paper.
The script gets a little slow if given a lot of images, and I am looking at way to increase the speed. Watch out for live example that I will post later.
Ready to take over the earth ?
Hey,
Over the past few week, I have "wasted" enough time playing a lot of casual games. These are typically games that have minimum learning curves, run across corporate networks, and can be played while taking short breaks in the middle of work. The paradigm "you rule the game, the game does not rule you" seems to attract many more people into this casual gaming segment.
A good example of this was Duels.com, that lets me visit my portal, issue challenges, and get back to work. The user interface was not great, and I wrote a lot of scripts and hacks to get it running for me. I wrote an automation script to quickly accept all challenge, to display my avatar as a badge, and even read the message RSS on my mobile using twitter.
All said and done, I seem to lose interest in the game, I seem to keep doing the same things over and over again. Issuing duels, selling stuff, trading etc; it is all the same. There was no real aim, no teams and alliances, or any new features coming up quickly. Given the community nature of the game, I presume that letting the community develop the game would be much more fruitful that the developers trying to keep up the pace.
It was an extension of this thought that I started writing a game of my own. For now, I would call it more a collaboration of social networking and second life, transcending the boundaries of corporate networks, as it is in plain HTML and Javascript.
To describe the game, let me give you the background. The player starts in any corner of a planet called earth. The integration with Google maps shows the player the actual location, and people can expand to occupy the entire planet, fighting each other, exploring all the time, etc. I was looking at something like recreating the idea of how humanity settled. I was also looking at possibilities of opening up the API like facebook did, to keep up with the demanding audience.
In short, this is a multiplayer online social networking game !! I am only working on weekends on this, and would love to hear your suggestions and any help that you can offer.
Over the past few week, I have "wasted" enough time playing a lot of casual games. These are typically games that have minimum learning curves, run across corporate networks, and can be played while taking short breaks in the middle of work. The paradigm "you rule the game, the game does not rule you" seems to attract many more people into this casual gaming segment.
A good example of this was Duels.com, that lets me visit my portal, issue challenges, and get back to work. The user interface was not great, and I wrote a lot of scripts and hacks to get it running for me. I wrote an automation script to quickly accept all challenge, to display my avatar as a badge, and even read the message RSS on my mobile using twitter.
All said and done, I seem to lose interest in the game, I seem to keep doing the same things over and over again. Issuing duels, selling stuff, trading etc; it is all the same. There was no real aim, no teams and alliances, or any new features coming up quickly. Given the community nature of the game, I presume that letting the community develop the game would be much more fruitful that the developers trying to keep up the pace.
It was an extension of this thought that I started writing a game of my own. For now, I would call it more a collaboration of social networking and second life, transcending the boundaries of corporate networks, as it is in plain HTML and Javascript.
To describe the game, let me give you the background. The player starts in any corner of a planet called earth. The integration with Google maps shows the player the actual location, and people can expand to occupy the entire planet, fighting each other, exploring all the time, etc. I was looking at something like recreating the idea of how humanity settled. I was also looking at possibilities of opening up the API like facebook did, to keep up with the demanding audience.
In short, this is a multiplayer online social networking game !! I am only working on weekends on this, and would love to hear your suggestions and any help that you can offer.
The Firefox Extensions that I have
Hey,
Two weeks of scripts at duels, and looks like my Firefox could not handle it any more. My Firefox just crashed last night, and since then, I have lost my Firefox profile also. I have finally managed to restore it, and since then, I have installed only those extensions that I would really use. To complete the exercise, I decided to list down all the extensions that are currently running.
Two weeks of scripts at duels, and looks like my Firefox could not handle it any more. My Firefox just crashed last night, and since then, I have lost my Firefox profile also. I have finally managed to restore it, and since then, I have installed only those extensions that I would really use. To complete the exercise, I decided to list down all the extensions that are currently running.
- Aardvark - An extension that allows me to explore the HTML of the page. This is similar to the Inspect action of FireBug, but I still have this extension installed as it allows me to remove HTML elements quickly, color divs, de-widhtfy, etc . These come in handy when I wanna print stuff, but don't want the advertisements clutter the view.
- BugMeNot - Untill single sign on comes into the mainstream, I would prefer to to visit certain sites without really registering them. This extension is integrated with the bug me not site.
- Cache Status - As a web developer, cached pages always frustrate me. Sitting quietly on mu status bar, this extension allows me to quickly see the status of my browser cache, and also clear it.
- Chicken Foot - An awesome extension for automating web tasks, this was an extension that I used for the recent duels scripts
- ChromeEdit Plus - For the extension developers, shows you the location of you install, and profile folders.
- Clean and Close - Replaces the "Close" button with a "Clean and Close" button. It deletes my download history quickly. I no longer really use this as I have Download Manager in my Status bar.
- Colorful Tabs - Not really very useful, but I like the colors in my browser. The tab color by the page is not very useful either.
- Copy Extended - Allows me to copy code not plain text, not as HTML. Useful when I copy paste code snippets.
- Cute Menus - This extensions adds an icon to my menus and stuff. The icon is worth a thousand words !!
- del.icio.us - The delicious extension that allows me to tag pages from the browser to my delicious list. The description window that pops up get a little annoying at times though.
- DOM Inspector - Comes with firefox pre-installed. After firebug, I don't really use this.
- Download Status Bar - Shows the download status on the status bar. Replaced the big window with indicators on the status bar. Good to see the status of all my downloads in the same window.
- DownThenAll - Helps me get all links from a site. This is particularly useful while reading tutorials or books offline.
- dragdropupload- A java based extension, helps me to drag files from my computer to upload them. Would be great if this was integrated with the File Upload Form Control
- Edit Css - Firebug does the job again, but sometimes, I just wanna look at the CSS and nothing else. Thats why this still stays in my browser
- ErrorZilla Mod - The error page for firefox gets better, with options like ping and google cache. Pretty useful when a site is broken, and you want to get around it.
- Extension Developer - For extension developers, a must have suite of tools.
- Extension Manager Extended - Used to show me the id and folder of the extensions. Firefox 2.0 already has such an option
- FasterFox - Firefox on steroids, this could be a nightmare for servers. However, I use the optimized settings, to strike a balance between server load and browsing speed.
- FEBE - A quick way to save losing you profiles. This is the extension that saved me from the crash yesterday. If only they have a "Backup Now !" button.
- Firebug - The best thing that could ever happen to Firefox, check out the website is all I can say.
- Firefox View - As a web developer, this helps me solve cross browser issues. Adds a context menu in IE, to see it in Firefox
- FireFTP - My FTP client
- Fission - Safari style progress bar in the address bar. Looks cool
- Flash Version Switcher - Lets me switch between various versions of the flash runtimes installed. Good for compatiability testing. I use this a lot when I do Laszlo development.
- Flash Tracer - I have the debug version of the flash player, and this is the place where the trace messages finally reach.
- FormFox - Shows me the location of the submit button. Quite handy to handle phishing. Sometimes the button background becomes yellow, and that is quite annoying
- FoxClocks - International times on my status bar. Handy when I am talking to my counterparts across the world
- ForxMarks - Helps me move my bookmarks across my home and work computer
- FullScreen - While viewing videos on Google Video or YouTube, I prefer a really full screen. This extension does exactly that.
- GetFile - A quick firefox simulation of wget. Stays in my systems as I prefer this kind of a wget !!
- GraphicsX - Saves the current web page as a PNG, so no more Alt-PrintScreen required. This is cleaner to get screen shots of web pages as they are rendered.
- Greasemonkey - A mini firefox extension developer ? Lots to write, so better check out the home page. To the uninitiated, this includes custom scripts in web pages, to make it more usuable.
- HackBar - Helps me rip the URL in the address bar apart, and is quite handy in unescaping url parameters, etc.
- HighlightAll - An eclipse style highlighter, marks all occurances of a word in the page or in a source. Helpful while reverse engineering Javascript.
- IE Tab - Uses the IE rendering engine in Firefox. So, here I can see all those sites that are IE specific, without problems
- IE Lite View - Opens the current page in IE
- iMacros - Another web automation tool, with a weird scripting language. All i use this is for record and replay on web pages.
- Javascript Debugger - Rest in peace. Firebug is here, so I don't use this.
- Link Alert- Adds a small icon showing me the type of link (zip file/ new window/ external link etc).
- Link Evaluator - Checks the validity of all the link on a page. A good sanity check on web pages that you develop.
- Long Titles - Prevents the tool tips from breaking.
- Measure It - Shows the exact dimensions of pages using a translucent measure box. Useful for web designers and developers
- Menu Editor - With so many tools around, I would want to unclutter my menus. This extension lets me have only those menu items that I want.
- More Tools Menu - Shows all my extensions in a "More Tools" rather than the "Tools" menu. Makes navigation easy.
- MozLab - Yet another tool suite for extension developers.
- MR Tech About:about - Adds all the possible about:* options on the Help menu. The options shown are "about :" tell you all details about your browser.
- Organize Status Bar - With so many tools, I prefer arranging my status bar in an order that is easier to manage. Very useful tool again.
- Page Update Checker - For those stupid sites that don't refresh when the content changes. I usually use this for my orkut scrap books
- Paragrasp - I read a lot on the net, and this extension lets me see which paragraph am I currently reading.
- PDF Download - Adds a couple of options when you try opening a PDF file in the browser. It even allows conversion of PDF to HTML (though this is a slow)
- Platypus - Greasemonkey scripts for the kiddies. Comes in handy for removing parts of a page (like google ads ? ) everytime you visit the page !
- Poster - A tool for interaction with URL, but I don't use this frequently
- Quick Preference Button - Adds a menu item that let me change the preferences of the browser quickly
- Server Spy - Shows the server version and details that a remote site sends back
- ShowIP - Shows the list of all remote IPs mapped on the DNS for that URL
- Splash - With firefox taking some time to load, this shows a quick splash screen. The flash image and words can be customized.
- Stumble Upon - Site companion for Stumble upon users
- Tamper Data - Indespensible tool (i would argue that this is better than LiveHTTP Headers) to see all the traffic flowing in and out of the browser
- Temporary Inbox - For fooling those registration sites that send you emails for registrations and then keep spamming you. Lets you create disposable mail boxes
- Twitter Bar - Twitter the URL that I am currently visiting
- UnHide Fields - Shows all the input type="hidden", and allows editing them. Good too to try injections of fields that you don't see. I prefer to do this in tamper data though.
- URL Parameters - Shows the GET or POST parameters submitted to a page. Easier than Tamper Data, but redirects make life difficult.
- User Agent Switcher - No one can now block me just because I am on Firefox, by looking at my user agent signature !!
- View Cookies - Detailed list of all cookies on my page
- Web Developer - Another indispensable tool for web developers
- XML Developer Toolbar - As web developer is for HTML, this is for XML !!
- XMLDAP identity Selector - Microsoft CardSpace integration with firefox
- XPath Helper - Quickly shows Xpath for XML docs. helps while reading RSS feeds
- XPanther - Another alternative to XPath Helper for doing more complex stuff
- YSlow - As if firebug was not enough, anther great too to profile pages and improve Javascript / overall web page performance. Heard that this was earlier an internal tool with YAHOO.
- Bookmarklets - This awesome set of book marklets that allow you to virtually do anything on the net !
I love showing off my DUAL in DUEL !!
Hey,
When I started writing this, I thought, "Sic, not another post on duels...I think there are other sites I should check out." But with the widget duels widget nearing completion, I though I should show it off to people. Putting the widget on my blog looks cool, and all of my friends are impressed with the XP and points I have.
Here is how my blog looks like, with the widget. I removed the meebo widget for now. This is how it looks on my local system. I am not able to publish it as it requires the server. I am currently running it on my local machine, and hence all that others could see is a server error. If anyone is generous enough to lend me some server space (JSP), or even if the people at Duels take a look at it, others can use it too.
The technical explanation of how i made this follows. Firstly, the assumption is that anyone looking at my blog is not logged into Duels.com. So all I could use is the information on my public avtars page. Another problem that I am having here is that I am not in the same domain as Duels.com (no XHR) , so I will have to use a proxy that gets me the information page, and extracts the data out of the page. That is where the requirement for a server comes to play. I have a JSP sitting on my Tomcat that fetches the page, and extracts out the SWF, path images, my player name and other details. The script is placed using an iFrame with a source pointing to a HTML page on my local machine. Currently, I am only showing only the last duel when the page was loaded.
As an extension, I am also planning to use XHR to update the duels that I have fought and the equipment that I have got. Making the widget show the dynamic details would require a little more work, but tomorrow is a holiday (Indian Independence day), so I am keeping me busy for tomorrow. This weekend, I am also looking at porting this to facebook, something that will allow people to fight directly from facebook. It is a little challenging, and I will definitely require my server to proxy (unless someone is generous to donate a server).
To end, I think that making this is not technically challenging, but in my humble opinion, people would want something like this. So why wait for the developers at Duels.com to show off my DUAL in the DUEL world ??
[If you want to contact me please leave your email ids in the meebo chat box]
When I started writing this, I thought, "Sic, not another post on duels...I think there are other sites I should check out." But with the widget duels widget nearing completion, I though I should show it off to people. Putting the widget on my blog looks cool, and all of my friends are impressed with the XP and points I have.
Here is how my blog looks like, with the widget. I removed the meebo widget for now. This is how it looks on my local system. I am not able to publish it as it requires the server. I am currently running it on my local machine, and hence all that others could see is a server error. If anyone is generous enough to lend me some server space (JSP), or even if the people at Duels take a look at it, others can use it too.
The technical explanation of how i made this follows. Firstly, the assumption is that anyone looking at my blog is not logged into Duels.com. So all I could use is the information on my public avtars page. Another problem that I am having here is that I am not in the same domain as Duels.com (no XHR) , so I will have to use a proxy that gets me the information page, and extracts the data out of the page. That is where the requirement for a server comes to play. I have a JSP sitting on my Tomcat that fetches the page, and extracts out the SWF, path images, my player name and other details. The script is placed using an iFrame with a source pointing to a HTML page on my local machine. Currently, I am only showing only the last duel when the page was loaded.
As an extension, I am also planning to use XHR to update the duels that I have fought and the equipment that I have got. Making the widget show the dynamic details would require a little more work, but tomorrow is a holiday (Indian Independence day), so I am keeping me busy for tomorrow. This weekend, I am also looking at porting this to facebook, something that will allow people to fight directly from facebook. It is a little challenging, and I will definitely require my server to proxy (unless someone is generous to donate a server).
To end, I think that making this is not technically challenging, but in my humble opinion, people would want something like this. So why wait for the developers at Duels.com to show off my DUAL in the DUEL world ??
[If you want to contact me please leave your email ids in the meebo chat box]
Fooling MMORPGS - The Turing Factors
Hey,
In the last week, you would have seen my blog scattered with a lot of posts on a game site called Duels.com. It is a MMPRPG game with a blend of Diablo and WOW. Though I started playing it the regular way, I soon got a little lazy and wrote a script to throw random challenges to everyone. In no time, my experience points were soaring, and I was soon it the top list of duelists.
Hoever, I did inform the developers of the potential exploit, and it has been fixed since then. Though it was a bad move to have released the script it public, it did get a lot of people thinking. A couple of people pinged me on a script, and I realized that the game was not only a Massively Multiplayer Online Role Playing Game. It seemed more like a Multiplayer Online "Script" playing game. This actually meant that scripts would be fighting each other, and idea that i really cool. Writing scripts for the site is simple, and this is a good way for enthusiasts to learn new technology quickly. Many people told me that they were now into learning chicken foot. I was talking to a friend about making the process of issuing challenges quicker. It seemed more like a computer science optimization class. The technical discussions were interesting, and it would be nice to play against scripts, that are getting better all day !
However, here are some issues that script writers may have to watch out against. These points could give away the bots, so watch out. I hope that the developers get a chance to read this, so that they can nail down the cheaters.
Referrer Issues
A couple of scripts that I was looking at do an XMLHTTPRequest to issue challenges and accept challenges. In the case when a human plays, the browser always sends the referrer page at the minimum for every request. A simple scan of the HTTP log will let the developers know of all the people who have gained experience by scripts
Bread Crumbs
The process of issuing challenges covers a whole lot pages. The scripts don't really go though the different pages. If the developers implement bread crumbs, script will find it difficult. From the time a user starts the process of issuing a challenge, till the challenge is issued, the user gors through many pages. If each page would show up with a hidden input field that has the hash of the previous page, the scripts will have to parse all the different pages, making them slower.
Captchas
Another option is the use of captchas. The only problem with captchas is that they are not very user friendly, and a player would hate typing in a captcha every time he issues a challenge. As a compromise, if a player is issuing challenge very fast (resembling a bot), an ocassional captcha could pop up.
DOM Garbling
Most scripts depend heavily on the static DOM structure of the HTML page to parse and use data. A simple javascript at the client side could be used that changes the DOM structure randomly, based on a key, without altering the look and feel of the page. Insertion of random invisible page elements, playing around with Ids are some of the ways of achieving this. A new tree structure would screw up the life of a bot (if it has any), but would have no real impact on the user. If this DOM garbling occurs at the server side, it is even better. Doing it at the server side is a little application specific, but coming up with a client side DOM garbler is easy, and cna be applied for many web sites.
Flash - Javascript Intertwining
Another alternative that can be considered is the combination of Flash and Javascript. Certain actions could be in the Flash movie, and writing good screen scrappers for Flash is not a trivial task. A flash scrapper means the power to read and understand the SWF format, that is complex in itself.
Let us see how the developers stop the scripts. Till then, lets the war of the scripts continue !!
In the last week, you would have seen my blog scattered with a lot of posts on a game site called Duels.com. It is a MMPRPG game with a blend of Diablo and WOW. Though I started playing it the regular way, I soon got a little lazy and wrote a script to throw random challenges to everyone. In no time, my experience points were soaring, and I was soon it the top list of duelists.
Hoever, I did inform the developers of the potential exploit, and it has been fixed since then. Though it was a bad move to have released the script it public, it did get a lot of people thinking. A couple of people pinged me on a script, and I realized that the game was not only a Massively Multiplayer Online Role Playing Game. It seemed more like a Multiplayer Online "Script" playing game. This actually meant that scripts would be fighting each other, and idea that i really cool. Writing scripts for the site is simple, and this is a good way for enthusiasts to learn new technology quickly. Many people told me that they were now into learning chicken foot. I was talking to a friend about making the process of issuing challenges quicker. It seemed more like a computer science optimization class. The technical discussions were interesting, and it would be nice to play against scripts, that are getting better all day !
However, here are some issues that script writers may have to watch out against. These points could give away the bots, so watch out. I hope that the developers get a chance to read this, so that they can nail down the cheaters.
Referrer Issues
A couple of scripts that I was looking at do an XMLHTTPRequest to issue challenges and accept challenges. In the case when a human plays, the browser always sends the referrer page at the minimum for every request. A simple scan of the HTTP log will let the developers know of all the people who have gained experience by scripts
Bread Crumbs
The process of issuing challenges covers a whole lot pages. The scripts don't really go though the different pages. If the developers implement bread crumbs, script will find it difficult. From the time a user starts the process of issuing a challenge, till the challenge is issued, the user gors through many pages. If each page would show up with a hidden input field that has the hash of the previous page, the scripts will have to parse all the different pages, making them slower.
Captchas
Another option is the use of captchas. The only problem with captchas is that they are not very user friendly, and a player would hate typing in a captcha every time he issues a challenge. As a compromise, if a player is issuing challenge very fast (resembling a bot), an ocassional captcha could pop up.
DOM Garbling
Most scripts depend heavily on the static DOM structure of the HTML page to parse and use data. A simple javascript at the client side could be used that changes the DOM structure randomly, based on a key, without altering the look and feel of the page. Insertion of random invisible page elements, playing around with Ids are some of the ways of achieving this. A new tree structure would screw up the life of a bot (if it has any), but would have no real impact on the user. If this DOM garbling occurs at the server side, it is even better. Doing it at the server side is a little application specific, but coming up with a client side DOM garbler is easy, and cna be applied for many web sites.
Flash - Javascript Intertwining
Another alternative that can be considered is the combination of Flash and Javascript. Certain actions could be in the Flash movie, and writing good screen scrappers for Flash is not a trivial task. A flash scrapper means the power to read and understand the SWF format, that is complex in itself.
Let us see how the developers stop the scripts. Till then, lets the war of the scripts continue !!
Chickening out of Duels.com
Hey,
A little more work, and here I have ,the ChickenFoot script to issue challenges to all my equals. The script is still within the boundaries of the game, all that this script does is remove the pain of manually challenging the players.
Before we get into the details of the script, a quick note on why I chose chicken foot over any other way of doing it. Apparently , chickenfoot is like greasemonkey (on steroids) spread across pages. I would still classify it as a web automation tool. The libraries that it has are good enough to do quick and dirty scripting.
Anyone with basic knowledge on how it works can cook up something like the following scriptlet.
The script is to be executed when on the battle page, viewing duelists. It challenges all players that are displayed in the current battle page. This allows the customization of the et of players who are challenged, to include only online players, only NPCs, filtered by levels, etc.
The script starts scraping the page by looking at the table with the "playerLists"id. It navigates to the child "tr" elements and picks up the URLs of all the duelists in the page. After saving it to an array, the script then start for all duelists in the array, go to their page, click on the challenge button. Then submits the next 2 forms that correspond to selection of the scroll and path power respectively. For now, I have hardcoded them, but it can be made a default selection.
On closer inspection, you would realize that the document.forms are submitted only when the page is loaded.
The final script looks something like this.
wait();
clear();
output("=====Starting to issue challenges=====");
var challengeList;
for (table = find("table"); table.hasMatch; table = table.next)
{
if (table.element && table.element.id == "playerlist")
{
challengeList = table.element;
}
}
var contestants = [];
challengeList = challengeList.childNodes[1];
for (var i = 2; i <>
{
if (challengeList.childNodes[i].childNodes[3])
{
contestants.push(challengeList.childNodes[i].childNodes[3].childNodes[0].href);
}
}
for (m in contestants)
{
go(contestants[m],true);
wait();
output("Challenging : " + contestants[m]);
var m = find("challenge");
if (m.element && m.element.src == "http://images.duels.com/images/button_challenge_grey.gif")
{
output("--There is already an outstanding challenge");
}
else
{
wait();
whenLoaded(function(){click(find("challenge").element);});
wait();
whenLoaded(function(){document.forms[0].submit();});
wait();
whenLoaded(function()
{
insert(after("Openers"),"<input value = '214' name = 'data[SkillsRank][SkillsRank][]' >");
document.forms[0].submit();
}
);
wait();
output("--challenge issued")
}
}
output("=======All challenges issued========")
[Please note that the script has a syntax error. I dont want to promote cheating in the game. People who are smart enough to fix the syntax error already know how to write the script. If you still want the script, ping me.]
A little more work, and here I have ,the ChickenFoot script to issue challenges to all my equals. The script is still within the boundaries of the game, all that this script does is remove the pain of manually challenging the players.
Before we get into the details of the script, a quick note on why I chose chicken foot over any other way of doing it. Apparently , chickenfoot is like greasemonkey (on steroids) spread across pages. I would still classify it as a web automation tool. The libraries that it has are good enough to do quick and dirty scripting.
Anyone with basic knowledge on how it works can cook up something like the following scriptlet.
The script is to be executed when on the battle page, viewing duelists. It challenges all players that are displayed in the current battle page. This allows the customization of the et of players who are challenged, to include only online players, only NPCs, filtered by levels, etc.
The script starts scraping the page by looking at the table with the "playerLists"id. It navigates to the child "tr" elements and picks up the URLs of all the duelists in the page. After saving it to an array, the script then start for all duelists in the array, go to their page, click on the challenge button. Then submits the next 2 forms that correspond to selection of the scroll and path power respectively. For now, I have hardcoded them, but it can be made a default selection.
On closer inspection, you would realize that the document.forms are submitted only when the page is loaded.
The final script looks something like this.
wait();
clear();
output("=====Starting to issue challenges=====");
var challengeList;
for (table = find("table"); table.hasMatch; table = table.next)
{
if (table.element && table.element.id == "playerlist")
{
challengeList = table.element;
}
}
var contestants = [];
challengeList = challengeList.childNodes[1];
for (var i = 2; i <>
{
if (challengeList.childNodes[i].childNodes[3])
{
contestants.push(challengeList.childNodes[i].childNodes[3].childNodes[0].href);
}
}
for (m in contestants)
{
go(contestants[m],true);
wait();
output("Challenging : " + contestants[m]);
var m = find("challenge");
if (m.element && m.element.src == "http://images.duels.com/images/button_challenge_grey.gif")
{
output("--There is already an outstanding challenge");
}
else
{
wait();
whenLoaded(function(){click(find("challenge").element);});
wait();
whenLoaded(function(){document.forms[0].submit();});
wait();
whenLoaded(function()
{
insert(after("Openers"),"<input value = '214' name = 'data[SkillsRank][SkillsRank][]' >");
document.forms[0].submit();
}
);
wait();
output("--challenge issued")
}
}
output("=======All challenges issued========")
[Please note that the script has a syntax error. I dont want to promote cheating in the game. People who are smart enough to fix the syntax error already know how to write the script. If you still want the script, ping me.]
Sign On Manager Improved
Hi,
A little more changes to SignOn Manager, and I now have options to change you username, password and login options through the userscripts menu. There still seems to be some problems with GM_registerMenuCommand that I am trying to resolve. This removes the problem of the infinate loop if you save a wrong username/password combination in the script that I wrote.
Untill then, you can setup the login manager to automatically login to pages that you visit daily from your personal machine. The form submit also allows logins that are initiated by javascript instead a plain document.form[x].submit() functions.
During this, I also added the implementation of the GM_xmlhttpRequest function to the greasemonkey development framework that I was writing. I need to test it out. In the meanwhile, if you have suggestions, please do ping me.
A little more changes to SignOn Manager, and I now have options to change you username, password and login options through the userscripts menu. There still seems to be some problems with GM_registerMenuCommand that I am trying to resolve. This removes the problem of the infinate loop if you save a wrong username/password combination in the script that I wrote.
Untill then, you can setup the login manager to automatically login to pages that you visit daily from your personal machine. The form submit also allows logins that are initiated by javascript instead a plain document.form[x].submit() functions.
During this, I also added the implementation of the GM_xmlhttpRequest function to the greasemonkey development framework that I was writing. I need to test it out. In the meanwhile, if you have suggestions, please do ping me.
iAccept Duels.....
A little work, and looks like I have the script ready, without any pain. This is a very simple version, it automatically accepts all challenges issued to you. I am not really publishing this script, but if you want to see how the script works (strictly out of technical curiosity), please ping me using meebo-me widget on this page. I recorded this script using iMacros, made a little changes, and got it working.
Here is a screenshot of the script in action, and this script relieves me of the pain of manually accepting challenges. I think that the guys at Duels.com should have made the UI a little more AJAX based, to be able to accept challenges on the same page.
About the nature of this script, I would not really call this a hack in any way as all it does it automation of work. I think it still is inside the ethical boundary as it only simplifies work, well, thats what iMacros is meant to do.
The main reason i wrote this script was to get a little familiar with iMacros, a tool that has stayed on my extensions-to-explore list for quite some time now. I am planning to use it for automation testing of a web page that I am currently building. The experience has been good till now, and I would recommend the tool for simple automation of web activity.
The script that is generated after recording is a little weird looking, and I am not sure if I would edit or program in that language. So I plan to limit iMacros to basic automation only. I would leave complex logic to be done on ChickenFoot instead.
Watch out for updates on chicken foot that I plan to post later in the day. You could also subscribe to the feed of this blog.
Here is a screenshot of the script in action, and this script relieves me of the pain of manually accepting challenges. I think that the guys at Duels.com should have made the UI a little more AJAX based, to be able to accept challenges on the same page.
About the nature of this script, I would not really call this a hack in any way as all it does it automation of work. I think it still is inside the ethical boundary as it only simplifies work, well, thats what iMacros is meant to do.
The main reason i wrote this script was to get a little familiar with iMacros, a tool that has stayed on my extensions-to-explore list for quite some time now. I am planning to use it for automation testing of a web page that I am currently building. The experience has been good till now, and I would recommend the tool for simple automation of web activity.
The script that is generated after recording is a little weird looking, and I am not sure if I would edit or program in that language. So I plan to limit iMacros to basic automation only. I would leave complex logic to be done on ChickenFoot instead.
Watch out for updates on chicken foot that I plan to post later in the day. You could also subscribe to the feed of this blog.
Reverse Engineering Javascript
The beauty of a Web Application is reflected in the way it has it Javascript, CSS and HTML is structured. Reading well written Javascript is fun in itself, exploring the "behind the screens" of interesting web pages can soon grow obsessive.
However, with Javascript obfuscation and minimization, it becomes really difficult to understand the nuances and flow of the page. In addition to this, since Javascript is usually associated with events, looking at the objects in isolation, with comments removed is seldom useful. Though firebug can appear to be a very helpful tool, there are still some features that I would really want.
Firstly, I would like to add break points no only to line numbers, but also break on events. The notion of "break on next mouse click" would be an interesting problem to solve, specially given the event bubbling model in the browser. If this was configurable, the exact code executed during a particular event can be caught easily during a reverse engineering exploration.
Another interesting feature would be the option of pretty print. This was a feature that was available in Venkman, but that was not very great. Given the inherent problem with the Javascript language about the end of termination token, this is not an easy problem to solve. However, associating firebug to an external editor (eg. aptana) could be a great idea as that would give a syntax highlighting during reverse engineering.
As firebug is also Open Source, and I am currently looking at the possibilities of extending it to suit my needs, and make reverse engineering of javascript easier.
However, with Javascript obfuscation and minimization, it becomes really difficult to understand the nuances and flow of the page. In addition to this, since Javascript is usually associated with events, looking at the objects in isolation, with comments removed is seldom useful. Though firebug can appear to be a very helpful tool, there are still some features that I would really want.
Firstly, I would like to add break points no only to line numbers, but also break on events. The notion of "break on next mouse click" would be an interesting problem to solve, specially given the event bubbling model in the browser. If this was configurable, the exact code executed during a particular event can be caught easily during a reverse engineering exploration.
Another interesting feature would be the option of pretty print. This was a feature that was available in Venkman, but that was not very great. Given the inherent problem with the Javascript language about the end of termination token, this is not an easy problem to solve. However, associating firebug to an external editor (eg. aptana) could be a great idea as that would give a syntax highlighting during reverse engineering.
As firebug is also Open Source, and I am currently looking at the possibilities of extending it to suit my needs, and make reverse engineering of javascript easier.
Fighting back in Duels.com....using iMacros
Hey,
Duels.com is finally back, with a couple of changes to the game play. The total numbers of players hooked on to the game has also risen, so has the complexity of their HTML challenge issue forms !
The spoiler hack that I had earlier written to advance in the game is no longer going to work as they have made some interesting and smart changes. Getting around the current conditions is a little tricky, but someone with general knowledge of Javascript can actually write a script to do this. The process of advancing is now a little more involving and time consuming. I am NOT writing a script for this, specially after the reactions to the last hack, but would surly want to discuss the nuances of this new hack that someone could potentially exploit.
Also, writing a script for the current form submissions involves a little more of HTML parsing and stuff, and I am not sure if it is worth that effort. Last night, I was talking to a "certain friend of mine" who did succeed in getting something that looked like a good script, but there were way too many things remaining to do, before the script got working. Added to all these was the fact that there was a random id being passed, hidden in the form, we needed a map between the actual player names and the ids, to issue the challenges etc.
However, I realized that the fundamental way the game functions has not really changed. I was expecting the people at Duels.com to add certain conditions like losing in XP points on losing duels above a certain level, prevent challenge spamming to players etc. Also, they still are not checking for the referrer URL to all incoming challenge requests. Another problem with writing the script is that it has to be constantly updated as the site changes. As I am not a developer with Duels.com, I don't think it would be a great idea for me to constantly update stuff that I have written for fun.
So here is the solution for all these. There are two parts to it, some way to accept all challenges that are thrown to me, and another way to search for people who are in my XP level, and challenge only them (also only those who are online). A script for this would be complex, and that is where the firefox extension, iMacros comes into play. iMacros is basically a record and playback browser tool for firefox. It is simple for a novoice to use, but the script that is generated can actually be changed to give enough flexibility. iMacros in a sense is a scaled down version of a HTML automated test framework like SilkTest
Another option that I am considering is using a combination of Chicken foot and Aadavark, but I may drop it in favor of iMacros, primarily because iMacros allows me to record, while in chickenfoot, I need to script down elements. Lets see what comes out of this experiment !!
Duels.com is finally back, with a couple of changes to the game play. The total numbers of players hooked on to the game has also risen, so has the complexity of their HTML challenge issue forms !
The spoiler hack that I had earlier written to advance in the game is no longer going to work as they have made some interesting and smart changes. Getting around the current conditions is a little tricky, but someone with general knowledge of Javascript can actually write a script to do this. The process of advancing is now a little more involving and time consuming. I am NOT writing a script for this, specially after the reactions to the last hack, but would surly want to discuss the nuances of this new hack that someone could potentially exploit.
Also, writing a script for the current form submissions involves a little more of HTML parsing and stuff, and I am not sure if it is worth that effort. Last night, I was talking to a "certain friend of mine" who did succeed in getting something that looked like a good script, but there were way too many things remaining to do, before the script got working. Added to all these was the fact that there was a random id being passed, hidden in the form, we needed a map between the actual player names and the ids, to issue the challenges etc.
However, I realized that the fundamental way the game functions has not really changed. I was expecting the people at Duels.com to add certain conditions like losing in XP points on losing duels above a certain level, prevent challenge spamming to players etc. Also, they still are not checking for the referrer URL to all incoming challenge requests. Another problem with writing the script is that it has to be constantly updated as the site changes. As I am not a developer with Duels.com, I don't think it would be a great idea for me to constantly update stuff that I have written for fun.
So here is the solution for all these. There are two parts to it, some way to accept all challenges that are thrown to me, and another way to search for people who are in my XP level, and challenge only them (also only those who are online). A script for this would be complex, and that is where the firefox extension, iMacros comes into play. iMacros is basically a record and playback browser tool for firefox. It is simple for a novoice to use, but the script that is generated can actually be changed to give enough flexibility. iMacros in a sense is a scaled down version of a HTML automated test framework like SilkTest
Another option that I am considering is using a combination of Chicken foot and Aadavark, but I may drop it in favor of iMacros, primarily because iMacros allows me to record, while in chickenfoot, I need to script down elements. Lets see what comes out of this experiment !!
Undoing the damage
Hey,
A small script in some spare time I had, and people are getting really angry on me. I am talking about the duels.com script that I wrote last night to randomly throw challenges to people. I figured out that regardless of whether you win or lose, you can enhanced your XP points.
I tried hard, but could not really get to the developers of the game, so I had to leave a message in the "BUG LIST" about this possible exploit. I thought that this was a bug, and hence put it there. Apparently, that was not a great idea as I had also put in the source of the script, and looks like many people have used to script to gain unfair advantage. I had appealed to use this script responsibly, but looks like no one listened !
Anyway, to set things right, there is definitely a way to set things to normal. If you realize, the normal way people issue challenges they go from a user page [http:\\duesl.com\player] to the challenge page [http:\\duels.com\challenges\challenge]. Hence, if the developers of the game could simply parse the log and look at challenges issues without a HTTP referral. Also, they could remove all the challenges that have a loadout id 548 (thats my loadout id). That will delete all the challenges that I have issued, but I that it is fine.
But the best thing that they could do is have a "Contact US" link, so that people can directly talk to them, and avoid hate mails like I have got !! :(
A small script in some spare time I had, and people are getting really angry on me. I am talking about the duels.com script that I wrote last night to randomly throw challenges to people. I figured out that regardless of whether you win or lose, you can enhanced your XP points.
I tried hard, but could not really get to the developers of the game, so I had to leave a message in the "BUG LIST" about this possible exploit. I thought that this was a bug, and hence put it there. Apparently, that was not a great idea as I had also put in the source of the script, and looks like many people have used to script to gain unfair advantage. I had appealed to use this script responsibly, but looks like no one listened !
Anyway, to set things right, there is definitely a way to set things to normal. If you realize, the normal way people issue challenges they go from a user page [http:\\duesl.com\player] to the challenge page [http:\\duels.com\challenges\challenge]. Hence, if the developers of the game could simply parse the log and look at challenges issues without a HTTP referral. Also, they could remove all the challenges that have a loadout id 548 (thats my loadout id). That will delete all the challenges that I have issued, but I that it is fine.
But the best thing that they could do is have a "Contact US" link, so that people can directly talk to them, and avoid hate mails like I have got !! :(
When you play a game, try enjoying it, you MORON
Hey,
I think you play any game to enjoy it. May be winning or losing is secondary. Whatever the reason is, I have been getting many requests for the script, and here I am, releasing it out.
The script is not a great hack or something. It just takes advantage of the fact that the more challenges you issue, the faster you can grow in the game. The win to lose ration would be bad, but who cares, once you are at a higher level, you can start winning all games. The script can be used as a bookmarklet.
Before I do release it, I would like to apologize to all those from whom, I am stealing the fun of playing. I hope the guys at Duels.com change the rules so that issuing challenges is not proportional to your growth in the game.
The scripts are located at http://tinyurl.com/2cprfl and http://tinyurl.com/27qn93. I suggest that you read the scripts first before executing, as using this as a bookmarklet would give the script complete access to you Duels.com session. So, all you have to do now is copy paste the following line in your browser window, after you have logged into the site.
javascript:(function(){var x = document.createElement("script");x.src=" http://tinyurl.com/2cprfl ";userScript="http://tinyurl.com/27qn93";document.body.appendChild(x);})()
All it does is create a new script tag, include a couple of YUI files, and then include the main DuelHack.js file. I have tested it on firefox and it work. I am NOT going to testing it on IE, primarily because even if I discover bugs, I am not in a mood to fix it !! (Sorry, I have a game of Diablo II to catch up with)
For now, i am issuing a challenge with a LoadOut of ID = 548. If it works for other also, I think we have found a hack. We could potentially have a great loadout, that is not really ours, and challenge others using that !! Still waiting to check that out.
I think that this is not a way to play a game. Some changes in the rules could make the game better. The people at Duels.com should, at the minimum, randomize the defender Ids, so that the defenders cannot be easily guessed (Just like session Id cookies are randomized). Also, they could have some penalty for losing a game, so that people don't throw random challenges to everyone. I mean, in any game, would you not be penalized for losing ? The last part, if this was on facebook, I would love to play the game there.
Also, please be warned that running this would repeatedly hit their server, and could make matters worse for the Duels team as they are already struggling with performance issues. So please use this script responsibly.
I think you play any game to enjoy it. May be winning or losing is secondary. Whatever the reason is, I have been getting many requests for the script, and here I am, releasing it out.
The script is not a great hack or something. It just takes advantage of the fact that the more challenges you issue, the faster you can grow in the game. The win to lose ration would be bad, but who cares, once you are at a higher level, you can start winning all games. The script can be used as a bookmarklet.
Before I do release it, I would like to apologize to all those from whom, I am stealing the fun of playing. I hope the guys at Duels.com change the rules so that issuing challenges is not proportional to your growth in the game.
The scripts are located at http://tinyurl.com/2cprfl and http://tinyurl.com/27qn93. I suggest that you read the scripts first before executing, as using this as a bookmarklet would give the script complete access to you Duels.com session. So, all you have to do now is copy paste the following line in your browser window, after you have logged into the site.
javascript:(function(){var x = document.createElement("script");x.src=" http://tinyurl.com/2cprfl ";userScript="http://tinyurl.com/27qn93";document.body.appendChild(x);})()
All it does is create a new script tag, include a couple of YUI files, and then include the main DuelHack.js file. I have tested it on firefox and it work. I am NOT going to testing it on IE, primarily because even if I discover bugs, I am not in a mood to fix it !! (Sorry, I have a game of Diablo II to catch up with)
For now, i am issuing a challenge with a LoadOut of ID = 548. If it works for other also, I think we have found a hack. We could potentially have a great loadout, that is not really ours, and challenge others using that !! Still waiting to check that out.
I think that this is not a way to play a game. Some changes in the rules could make the game better. The people at Duels.com should, at the minimum, randomize the defender Ids, so that the defenders cannot be easily guessed (Just like session Id cookies are randomized). Also, they could have some penalty for losing a game, so that people don't throw random challenges to everyone. I mean, in any game, would you not be penalized for losing ? The last part, if this was on facebook, I would love to play the game there.
Also, please be warned that running this would repeatedly hit their server, and could make matters worse for the Duels team as they are already struggling with performance issues. So please use this script responsibly.
The best way to play a game..it to write a script to do it !!
Hey,
I love playing MMORPGs (Massively multilayer online role playing games). The only problem I have however is the firewall that prevents me from entering the fantasy worlds of warcraft or second life. That was the reason I jumped to the opportunity when I read about Duels.com on TechCrunch.
Poking a little more, I realized that I would be finally entering this world, given the fact that this was a plain HTML+JS application running on a simple browser. That would let me have some fun from a corporate network. So I went ahead and registered to start playing.
The objective of the game is simple. Challenge other players to a duel, gain gold and experience points, advance levels, and buy equipment. The challenges however was more like playing dice, with the player not really required to do anything. With a heavy dose of Diablo II background, I got into the world right away and spit out challenges to every player I could see online.
A few more minutes, and I realized that you are always in a win-win situation. Regardless of if you win or lose, you get experience points. Also, if u win, you get Gold to buy stuff, if you lose, you get tokens that can be redeemed to buy packs that have stuff in them. So, the entire idea of advancing in the games was to throw as many challenges as I could.
There goes the gaming spirit into the drain, an I started my Eclipse-Aptana editor to conjure some greasemonkey script to throw challenges to every player on the game. It was as simple as a form post to the URL - http:\\duels.com\challenge\challenges with parameters having a defenderID, a scrollID, and a couple of other things. The defenderID being sequential, a simple for-loop made me challenge every player in the fantasy world. A couple of hours, a hundred people accepting my challenges, and my experience levels was soaring high. I still kept minimum weapons (called loadouts) to give an impression that I was a dumb player at a higher level, hence making them comfortable to accept m challenge.
Another script to automatically accept my challenges, and my experience was accelerated. In a couple of hours, and I could even get to be the player with the maximum experience, and hence teh king of the world.
But no good deed goes unpunished, and the duels.com server crashed. due to the legendary digg effect. It is still down today, and I am waiting to see how much have I made, in this seemingly silly game. In the meanwhile, if you are curious about the script, ping me to get a copy.
Still waiting for the server to come alive. Till then, traversing other possible games that I could play, by writing scripts !!! :)
I love playing MMORPGs (Massively multilayer online role playing games). The only problem I have however is the firewall that prevents me from entering the fantasy worlds of warcraft or second life. That was the reason I jumped to the opportunity when I read about Duels.com on TechCrunch.
Poking a little more, I realized that I would be finally entering this world, given the fact that this was a plain HTML+JS application running on a simple browser. That would let me have some fun from a corporate network. So I went ahead and registered to start playing.
The objective of the game is simple. Challenge other players to a duel, gain gold and experience points, advance levels, and buy equipment. The challenges however was more like playing dice, with the player not really required to do anything. With a heavy dose of Diablo II background, I got into the world right away and spit out challenges to every player I could see online.
A few more minutes, and I realized that you are always in a win-win situation. Regardless of if you win or lose, you get experience points. Also, if u win, you get Gold to buy stuff, if you lose, you get tokens that can be redeemed to buy packs that have stuff in them. So, the entire idea of advancing in the games was to throw as many challenges as I could.
There goes the gaming spirit into the drain, an I started my Eclipse-Aptana editor to conjure some greasemonkey script to throw challenges to every player on the game. It was as simple as a form post to the URL - http:\\duels.com\challenge\challenges with parameters having a defenderID, a scrollID, and a couple of other things. The defenderID being sequential, a simple for-loop made me challenge every player in the fantasy world. A couple of hours, a hundred people accepting my challenges, and my experience levels was soaring high. I still kept minimum weapons (called loadouts) to give an impression that I was a dumb player at a higher level, hence making them comfortable to accept m challenge.
Another script to automatically accept my challenges, and my experience was accelerated. In a couple of hours, and I could even get to be the player with the maximum experience, and hence teh king of the world.
But no good deed goes unpunished, and the duels.com server crashed. due to the legendary digg effect. It is still down today, and I am waiting to see how much have I made, in this seemingly silly game. In the meanwhile, if you are curious about the script, ping me to get a copy.
Still waiting for the server to come alive. Till then, traversing other possible games that I could play, by writing scripts !!! :)
The "Pipes" in pipes.yahoo.com
The JavaScript guys at Yahoo have done another amazing job with Yahoo pipes. I got a little curious and started peeking into the Javascript source to see how the magic was done. As expected, it starts with using YUI from the central server. The file in this case that would be of particular interest is the maxwell_c.js. (Wondering if the guy who developed is called maxwell).
The file is compressed(as expected) and also obfuscated. The overall UI is simple to construct, but the actual pipes caught my attention. Though it looks like it is an image, there is not easy way to use images to draw something (a bezier curve) like that. A little more poking revealed that they had used the 2D canvas to pipes to actually do the drawing. No wonder I was looking at a lot math in the source code.
The magic function is the maxwell.Wire object that is responsible for drawing the wire, and also handling the one move and on remove events. The constructor first creates a canvas, attaches it to the document and also gets the type of rendering (blue or grey color). Then entire math resides in the maxwell.Wire.redraw function. This also uses the findBezierPoint function to allow smoother lines, for that curve effect. The function looks something like
One interesting design decision that would have been made is about placing all wires in one canvas, or having canvas for every wire. Yahoo seems to have gone with the latter. One reason I can think of is the problem of redrawing wires on dragging components. If all wires are on the same canvas, redrawing only selective lines is difficult. The XOR trick would work, but I have not come across a XOR compositing for lines (There is a XOR compositing for the entire canvas). Anyway, I think that adding a couple of canvas elements may slow the initial rendering, but the user interaction part is still intact.
So thats pretty much it, the way the interesting pipes are drawn in YAHOO pipes.
The file is compressed(as expected) and also obfuscated. The overall UI is simple to construct, but the actual pipes caught my attention. Though it looks like it is an image, there is not easy way to use images to draw something (a bezier curve) like that. A little more poking revealed that they had used the 2D canvas to pipes to actually do the drawing. No wonder I was looking at a lot math in the source code.
The magic function is the maxwell.Wire object that is responsible for drawing the wire, and also handling the one move and on remove events. The constructor first creates a canvas, attaches it to the document and also gets the type of rendering (blue or grey color). Then entire math resides in the maxwell.Wire.redraw function. This also uses the findBezierPoint function to allow smoother lines, for that curve effect. The function looks something like
ctxt.bezierCurveTo(_110[1][0],_110[1][1],_110[2][0],_110[2][1],_110[3][0],_110[3][1]);
Combining this point with source and destination co-ordinates, the bezierCurveTo of the canvas.getContext() object is called. A stroke object is used to determine the color of the line. There are two bezier curves drawn to give the outline effect. All other events like onMove or onResize call this redraw function. Also, a clearRectangle is called change the image on dragging of the actual window.One interesting design decision that would have been made is about placing all wires in one canvas, or having canvas for every wire. Yahoo seems to have gone with the latter. One reason I can think of is the problem of redrawing wires on dragging components. If all wires are on the same canvas, redrawing only selective lines is difficult. The XOR trick would work, but I have not come across a XOR compositing for lines (There is a XOR compositing for the entire canvas). Anyway, I think that adding a couple of canvas elements may slow the initial rendering, but the user interaction part is still intact.
So thats pretty much it, the way the interesting pipes are drawn in YAHOO pipes.
Gift Wrapping Javascript !!
Hey,
So celebration time is back at office, and I noticed people exchanging a lot of gifts. I was a little free than usual, and so, quickly thought of coming up with this gift wrapping HTML. Here is a demo page, and you could simple include that javascript source file from the original location. You could also change the look and feel of the gift wrapper, following the details inside the JS file. Here is how a gift wrap looks. Just paste the URL of the image that u wanna gift wrap.
The only trick here that the wrap open image is required to be fetched earlier so that the animation shows up properly. However, if you make the image, a part of some other object (if hidden), IE does not really show the animation. Note that the animation is not in loop, but stops after it is done.
Have fun !!
So celebration time is back at office, and I noticed people exchanging a lot of gifts. I was a little free than usual, and so, quickly thought of coming up with this gift wrapping HTML. Here is a demo page, and you could simple include that javascript source file from the original location. You could also change the look and feel of the gift wrapper, following the details inside the JS file. Here is how a gift wrap looks. Just paste the URL of the image that u wanna gift wrap.
The only trick here that the wrap open image is required to be fetched earlier so that the animation shows up properly. However, if you make the image, a part of some other object (if hidden), IE does not really show the animation. Note that the animation is not in loop, but stops after it is done.
Have fun !!