Tag Archives: Coding

Kongregate Night-mode script

This is a bookmarklet that sets a dark background colour on Kongregate game pages. The goal of this script is to dim nearly all the elements on the page, so as not to distract the player with bright lights, while keeping the chat box and achievement tabs legible.

The script works on Chrome 23 and IE 9, but doesn’t work at all only partially works in Firefox. The reason is this script relies on the $ and $$ functions that are defined in Kongregate’s javascripts. Apparently, Firefox doesn’t allow bookmarklets to access those. EDIT: This did not work in the “javascript:” URL version, but works in the bookmarklet version. However, still only half of it works in Firefox, because Firefox rejects my modifications to the CSS rules, throwing “Error: SecurityError: The operation is insecure.” This rule modification is required for dynamically inserted elements, like chat messages, to use the dark style. Firefox-compatible version to come later.

Kongregate Nightmode Screenshot

EDIT (Dec. 11, 2012): I updated the script to version 2, which colourizes more elements.

—> Instructions to install the script here <—

Read more »

Reversola – Reverse Engineering Sola Rola

Banner

Introduction

I was browsing the Kongregate forums one day, when a post caught my eye. It was a list of broken games on the site that still had achievements to earn, and the clever ways that people had found to progress in those games far enough to earn the achievements. Sola Rola: The Gravity Maze was one of the few that hadn’t been solved. This game was interesting because not only was it broken on Kongregate, it was also broken on every single other Flash game portal out there, including the game’s own sponsor Gimme5Games and the website of its creator, EvilFree Productions.

This was a simple physics-based game where you rotate the environment, similar to Loco Roco, but with its own cheeky characters having to navigate a maze. Around September 24, 2010, something changed that broke the game. No matter which website or computer you accessed it from, the game would show the sponsor logo and then a blank white screen. For two years, seemingly no one could figure it out, so in September of 2012, I set out to investigate it myself. Two weeks later, with the help of the Kongregate community, we were able to recreate the original levels to get a working version of the game for people to play and — if they are into this sort of thing — earn the achievements.

Why it Doesn’t Work

A few people already found out why the game doesn’t load. When the game starts, it tries to load two XML files: translate.xml, containing language strings, and levelList.xml, containing the level list. The problem is these files were ONLY located on the Gimme5Games server and the files are now nowhere to be found. This explains why the game was broken no matter which portal hosted the game (SWF file). After an hour of fruitless searching through internet archives, and several efforts to contact the developer, it was clear the original files would not be found. Another approach had to be taken.

In April of 2012, askon, a Kongregate user, posted the source code decompiled from the game’s SWF file, and a way to fool the game into starting with an empty XML file. All that was missing were the contents of that file — the level data! Fortunately, someone had recorded every single level of the game on Youtube, so we had hope to reconstruct the levels, if we only we knew the structure of the XML files. That is where I would come in. More on that later.

Getting the Game to Start

Network diagram

The hosts file entry bypasses the DNS lookup and redirects requests to our server.

When the game starts, it requests the XML files using ordinary HTTP requests to “http://www.gimme5games.com/solarola/translate.xml” and “http://www.gimme5games.com/solarola/levels/levelList.xml”. Since those are gone forever, we need the game to look for those files on a different server — one that we control. One obvious way would be to modify the compiled SWF file itself, however that wouldn’t allow us to earn achievements on the Kongregate site. Instead, we will redirect the request at the DNS lookup step. The easiest way to do this is to modify the “hosts” file of the local machine. Now, instead of asking a remote DNS server for the IP address of gimme5games.com, our PC will simply use the entry in our hosts file.

Read more »

Spoiler-free VODs for Eurocup 2012 on TSN

TSN.ca offers free video-on-demand (VOD) replays of full Eurocup matches this year. However, on the same page, they also have links to highlight clips, whose titles are unfortunately shown along with the final scores. So if you were planning to watch a full match, the result has already been spoiled once you visit the page. My brother brought this up, and I came up with the following solution – a user script to hide/remove the scores from the VOD page.

There are two scripts. The first simply removes any numbers from the Highlights row. The second removes the entire Highlights row, including the thumbnails (which could be a spoiler as well). Use whichever you like. The 2nd script is best for maximum protection from spoilers.

How to use these: AFTER the VOD page has already loaded, copy one of the scripts into your web browser’s address bar and hit <Enter>. (You will have to avert your eyes at the beginning to avoid seeing the scores before the script runs. An easy way is to resize the browser to a small size before going to the TSN site.)

Note for Google Chrome users: Chrome has a security measure that won’t let you copy/paste a URL with javascript in it. When you paste, “javascript:” is automatically removed from the beginning and it won’t work. The solution is to manually type “javascript:” in front of the URL. To minimize your typing, I suggest copying the script starting from the second letter, i.e. “avascript: …”, manually typing a “j”, then pasting the rest.

This was tested to work on Google Chrome (v19) and Mozilla Firefox (3.6).


/*
* Scripts to remove spoilers (scores/results) from TSN video on demand
* http://www.tsn.ca/window/euro2012/?episode=117716#episode117716
* Author: zAlbee, 2012-06-13
* http://zalbee.intricus.net/2012/06/spoiler-free-vods-for-eurocup-2012-on-tsn/
*/ 

Script 1. Replaces all numbers with X:

javascript:var list=document.querySelectorAll(".playlistitem");
for(var i in list){
var childs=list[i].childNodes;
for(var j=0;j<childs.length;j++){
var ch=childs[j];
if(ch.nodeName=="H3")ch.innerHTML=ch.innerHTML.replace(/[0-9]+/g,'X');
}
}

Same as above, but on one line:

javascript:var list=document.querySelectorAll(".playlistitem");for(var i in list){var childs=list[i].childNodes;for(var j=0;j<childs.length;j++){var ch=childs[j];if(ch.nodeName=="H3")ch.innerHTML=ch.innerHTML.replace(/[0-9]+/g,'X');}}

Result: 

Script 2. Removes entire highlights row:

javascript:document.getElementById("mainplaylist").style.display="none";void(0);

That’s it.

Solving Continuity Levels with Dijkstra’s Shortest Path

Continuity (game screen)

(This article was originally posted here.)

Continuity is a new Flash game that I was playing recently. It combines platforming and puzzle in a novel way – your character must jump from platform to platform collecting keys to open a door, but must do so inside mini-levels (squares). The macro-game is essentially an 8-puzzle (8 pieces in a 3×3 square grid), where you shift the puzzle pieces using the one empty space, such that your character can succeed in the mini-levels.

This game is perfectly solvable through logic and working backwards, though for some of the harder levels you need to keep a long memory of steps. In short, I became bored and impatient of solving the puzzles in my head, and decided after ~30 levels, it’d be more interesting to automate it by writing a solver.

I also took this opportunity to get familiar with Python, a language well known for its fast prototyping and easy learning curve. I have only worked in Python once, during a 4-month internship 4 years ago, but otherwise, my main skills are in C and Java. However the syntax required to write good algorithms and data structures in these “classic” languages can get quite long and annoying. So I coded up a Python script to solve the final two levels.

The rest of this post details how to develop the solution. The solution is relatively simple because we can just treat each exit in a square as a point in a directed graph, where each edge in the graph A->B specifies that point B is reachable from point A, and then apply a search algorithm through the graph. I chose Dijkstra’s shortest path algorithm, which runs fast and finds the best (shortest) solution. However, my program did require a lot of manual data entering to specify the paths/exits in each puzzle piece, so it wasn’t fully automatic. Perhaps Python has some magic that could automate this :). Lastly, I skipped solving the 8-puzzle, since it’s not necessary.

Read more »