[ #127 ] Hacking YourWorldOfText Permalink

Perl, Cool Added less than a year ago and last edited about two months ago

YourWorldOfText is a novel site that is like a big, collaborative whiteboard. It uses JQuery AJAX to send what you type to the server. I have reverse engineered (ha ha, that's the type of pretentious wanker I am, I use the term 'reverse engineered') the co-ordinate system and created a Perl script that let's you do some tricks with the site.

#!/usr/bin/env perl

use strict;
use warnings;

use constant MAX_X => 15;
use constant MAX_Y => 7;

my @thing = (0);

my $bigx_start = $thing[int rand scalar @thing];
my $bigy_start = $thing[int rand scalar @thing];
my $x_start = 0;
my $y_start = 0;

my $bigx = $bigx_start;
my $bigy = $bigy_start;
my ($x, $y) = ($x_start, $y_start);

my $starttime = (time() - 20) . '000';
my $output;
$output .= "\narr = [";

my $count = 0;
while (my $line = <>) {
    chomp($line);
    my @chars = split '', $line;
    $bigx = $bigx_start;
    for my $char (@chars) {
        $char = q(\\") if $char eq '"';
        $char = q(\\\\) if $char eq '\\';
        my $newtime = $starttime + ($count * 17);
        $output .= qq|[$bigy, $bigx, $y, $x, $newtime, "$char"], |;
        $x++;
        if ($x > MAX_X) {
            $x = 0;
            $bigx++;
        }
        $count++;
    }
    $x = $x_start;
    $y++;
    if ($y > MAX_Y) {
        $y = $y_start;
        $bigy++;
    }
}

$output .= "];\n";
$output .= "\n";
my ($prevbleep, $curbleep) = (0, 200);
while ($prevbleep < $count) {
    $output .= "setTimeout(function() { jQuery.post(window.location.pathname, {edits: arr.slice($prevbleep, $curbleep)}, YourWorld.editsDone, 'json') }, 10*$prevbleep);\n";
    $prevbleep = $curbleep;
    $curbleep += 200;
}
print $output;


chmod +x this script, run it and paste in some ASCII art (or figlet output, or whatever.) It will then print the javsascript code you need to insert the ASCII art on the site. You will need firefox and firebug - paste the JS into the firebug console and hit run... then wait to see your art come up on the site.

Pro Tip: Start with a small image, or only a word or two with figlet. Larger stuff takes longer.

Colophon

Django Python 960.gs Git Vim NetBSD Nginx

The Author

This is the blog of Brad Willis, a software engineer living in Brisbane.

Meta

Help
Latest entries

*BSD Agile Apache Apple apt Athletics Best-Practice Censorship Comedy Cool Crosswords Deployment Django English Exim Firefox Git Hardcore Health irssi Javascript Jira Languages Linux Makefile Mathematics Mobile Broadband Mutt MySQL NetBSD nginx Nokia OpenVZ OSX Perl Privacy Python Rant Requirements rsync Ruby Shell Slackware SQL SQLite SSH Standards Subversion Television Testing ThisBlog Vim VMWare (Fusion) VPN X zsh

Recent Entries

Checking for exceptions in doctests
Homer's Curling Speech
retry in Python
Vim Makefile tabs
Centos (or RH) IPTables
Converting ssh2 public keys to openssh
Vim comment hints
Context managers in Perl
Dish rotation
Git - fixing commit user
apt stuff
Using shell variables in AWK
Linux - Too many open files
Tell gvim to save and quit... remotely
Vim - automatically remove whitespace at EOL
Python - relative paths from within modules
TV Aspect Ratios
Git - Which commits are in your branch only?
Subversion setup cheat sheet
Force detach a screen session
Modify sudo's use of environment variables
Install all Perl modules
Mutt - delete old messages
OpenVZ VPS and swap space
fail2ban on NetBSD for ssh
NetBSD - Using sup
Python - testing for a sys.exit
Python Best Practice Link Dump
Python script names
Perl - Using an expensive module
Speed of git clone
Perl Modules with Custom Prefix
Perl: tr vs. s
Brilliant sysadmin Reference
Why is GRUB better than LILO?
Why is swap space important?
Perldoc Output
Git's Index
Jira Project Keys
Git GUI

Links

ChoppingBoard, DaveMisc, Project365, RageQuit